OOP - Object Oriented Programming, Past Papers

Object Oriented Programming MSc IT 2nd Term 2016 Past Paper UOS

"University of Sargodha Object Oriented Programming M.Sc. 2nd Term Exam 2016 question paper with objective and subjective questions about Java programming concepts"

University of Sargodha

M. Sc. 2nd Term Exam 2016
Subject: I. T
Paper: Object Oriented Programming (CMP: 2123)
Time Allowed: 2:30 Hour
Maximum Marks: 60

Objective Part (Compulsory)

Q.1. Write short answers of the following in 2-3 lines each. (2*12)
i. Define a class and an object?
ii. What are two main components of a class?
iii. Can we create a String object without “new” operator? If so, give an example?
iv. What is difference between next() and nextLine() methods?
v. Differentiate the access modifiers public and protected.
vi. For what purpose the keyword “this” is used?
vii. Differentiate abstract classes and concrete classes?
viii. What is Overloading of a method? Also give an example.
ix. Define polymorphism?
x. What is has-A relationship in classes?
xi. What is an Interface?
xii. What is dynamic dispatch?

Subjective Part (4*9)

Q.2. Create a Distance class with instance variable feet and inches. Write suitable parameterized constructor, getter and setter methods and a method to add two distance objects in such a way that if resultant inches exceed 12, feet should be incremented by 1 and inches decremented by 12 by using the statement dist3.add(dist1, dist2); where dist1, dist2 and dist3 are objects of Distance class.

Q.3. Write a program that creates a Parent class and Child class that inherits the Parent class. Demonstrate Upcasting by using Child class.

Q.4. Write a program that has Shape class and subclasses as Square and Circle. Use these classes to demonstrate Polymorphism.

Q.5. What do you mean by exception handling? What are the various keywords used in exception handling and also highlight their usage.

Q.6. Write a program that demonstrate the function of Object class acting as a parent class of all classes created in Java.

Q.7. Write a Java text stream class from java.io package to read text from one file and write to another text file.