Home /University Of Sargodha (UOS) /Object Oriented Programming

Object Oriented Programming/Web Programming BS/BSSE 2 Semester/Term University Of Sargodha (UOS) 2021

Object Oriented Programming/Web Programming BS/BSSE 2 Semester/Term University Of Sargodha (UOS) 2021 — page 1
Object Oriented Programming/Web Programming BS/BSSE 2 Semester/Term University Of Sargodha (UOS) 2021 — page 2

Discussion

Ask a question about this paper, or help someone else with theirs. Answers are emailed to whoever asked.

Your email is only used to send you replies and occasional Ustadni updates. It is never shown publicly.

Log in to post under your name

No questions yet — be the first to ask.

More Object Oriented Programming papers

See all

Paper text

19BSIT29394

University of Sargodha

BS 2nd Semester/Term Examination 2020

Subject: BSSE/IT Paper: Object Oriented Programming (CMPC-102)

Time Allowed: 2:30 Hours

Maximum Marks: 60

Note: Objective part is compulsory. Attempt any three questions from subjective part.

Objective Part

(Compulsory)

Q.1. Write short answers of the following in 2-3 lines each on your answer sheet.

(2*12)

i. Write purpose of copy constructor?-

ii.

How do you differentiate a class from an object?

iii.

What is Polymorphism?

iv.

Give example of exception handling.

V.

Give example of any overloaded operator of string class.

vi.

Can sorting help in searching array's elements?

vii.

vili.

What happens in case a user does not provide a constructor?

Discuss the relative merits of using protected access vs. using private access in base classes.

ix.

What is the purpose of information hiding?

X. What do you mean by default member-wise assignment?

xi. Differentiate: between sequence container and associative container.

xii. When do we need to allocate memory dynamically?

Subjective Part (3*12)

Q.2.

a) Compare in detail the following access modifiers.

(6)

i. Public

ii. Private

ili. Protected

Q.3.

b)

a)

Write a simple program that overloads the Unary prefix and postfix ++ and -- operators.

(6)

Write detailed note on Inheritance. Also clearly mention the relationship between base class

and derived class.

b)

Differentiate between virtual functions and pure virtual functions.

(8)

Q. 4.

(4)

Create a Distance class with instance variable feet and inches. Write suitable parameterized

constructor, getter and setter functions. Also write another function to subtract two objects of class

distance in such a way that if resultant inches are less than 1, feet should be decremented by 1 and

inches incremented by 12 by using the statement dist3.sub(distl, dist2); where distl, dist2 and dist3

are objects of class Distance and sub is a user-defined function.

Q.5.

a)

Give example of overloading a binary operator.

(12)

b)

(4)

Create an Address class that used Houseft, Streeth, and name of a City as data members of the

Address class. Create another class Person that defines Name as its data member and uses the

above Address class's data members as its data members. Use constructors (both with and

without parameters) to initialize the data members of Person class and display functions to

Q.6.

display the objects of the Person class.

Define a class for a bank account that includes the following data members.

(8)

Name of depositor, account number, type of account, balance amount in the account.

(12)

The class also contains the following member functions:

i. A constructor to assign initial value.

ii. A constructor to assign values from the user.,

ili. Deposit function to deposit some amount. It should display error message if deposited amount is

less than or equal to 0, and not add that amount in balance amount.

iv. Withdraw function to withdraw amount from an account. It should display an error message if

withdrawn amount is greater that balance amount in the account or if withdrawn amount is

negat ive.

Scanned with CamScanner

ustadni.com

Subject: 1.T/SE

Time Allowed: 02:30 Hours

University of Sargodha

208STT 20813

BS. 2ed Semester/Term Exam 2021

Paper: Object Oriented Programming (CMPC-102/CMP-2123)

Maximum Marks: 40

Note: Objective part is compulsory. Attempt any three questions from subjective part.

Objective Part

(Compulsory)

Q.1.

Write short answers of the following in 2-3 lines cach on your answer sheet.

i.

What are manipulators?

What is a friend function?

What is a ternary operator?

What is difference between JDK and JRE?

Differences between "this" and "super" keywords?

Can java support multiple inheritance? Justify your answer? -

vir.

vjity

What do you mean by Checked Exceptions?

What is the output of the following?

class Test

(2*8)

ustadni.com

public static void main (String args])

System.out.println(20 + 30 + "Javatpoint");

System.out.printin(" Javatpoint" + 20 + 30);

Subjective Part

(3*8)

Q.2.

Write a program that shows a constructor passing information about constructor failure to an exception

handler. Define class SomeClass, which throws an Exception in the constructor. Your program should

try to create an object of type SomeClass and catch the exception that's thrown from the constructor.

Q.3.

Write a Java application that uses the Math class to determine the answers for each of the following:

a. The square root of 30

b. The sine and cosine of 100

c. The value of the floor, ceiling, and round of 44.7

d. The larger and the smaller of the character K and the integer

70.

Q.4. Develop a program to read a text file. Process the read text by using String class methods in the

following order:

i. Convert all text into lower case (Hint use String's tolower method)

ii. Count no. of words in the text (Hint use String' split method).

Q,5.

Write a class named ShowStudent that instantiates a student object from the class you created and

assign values to its fields. Compute the Student grade point average, and then display all the values

associated with the student.

Q.6.

A publishing company that markets both book and audiocassette versions of its works. Create a class

ustad

called publication that stores the title (type string) and price (type float) of a publication also has an

abstract method "Oversize 0". From this class derive two classes: book, which adds a no of page (type

more than 500 pages, or a tape with a playing time longer than 90 minutes, is considered oversize. You

can access this method from main O and display the string "Oversize" for oversized books and tapes

when you display their data. Demonstrate polymorphic behavior by using these classes

Scanned with CamScanne

ustadni.com