OOP - Object Oriented Programming, Past Papers

Object Oriented Programming BSSE & IT 2nd Term 2016 Past Paper UOS

University of Sargodha BS 2nd Term 2016 Object Oriented Programming exam question paper

University of Sargodha
BS 2nd Term Examination 2016
Subject: I.T & Software Engineering
Paper: Object Oriented Programming (CMP:2123)
Time Allowed: 2:30 Hours
Maximum Marks: 60

Objective Part (Compulsory)

Q1. Write short answers of the following in 2-3 lines each. (2*12)

  1. Does Java support Multiple Inheritance?
  2. What is Polymorphism?
  3. What is Object Serialization?
  4. What is the purpose of finally() block?
  5. Can a constructor be overloaded?
  6. Can one try block have multiple catch blocks?
  7. Differentiate between abstract class and concrete class?
  8. What is this keyword and its purpose? Give an example?
  9. Can we override Static Methods if not why?
  10. What is Wrapper class in java?
  11. What is meant by Standard System Exception? Give two examples.
  12. What packages does java provide for graphics programming?

Subjective Part (4*9=36)

Note: Attempt any four questions. All questions carry equal marks.

Q2. Create a class publication (title, price). Create two classes named books (no of pages) and tape (playing time) from it. Write appropriate constructors, print() and get() functions for each class. Write an application that demonstrates using objects of each class.

Q3. Create an abstract Auto class with fields for the car make and price. Include get and set methods for these fields; the setPrice() method is abstract. Create two subclasses for individual automobile makers (for example Mehran, Toyota) and include appropriate setPrice() methods in each class (i.e. Rs 600000 or Rs 1800000). Finally, write an application that uses Auto class and subclasses to display information about different cars.

Q4. Write down a class Time having fields (hrs, mins, secs), containing no argument constructor, three argument constructor and copy constructor. Also write down a method inc_time() that increments seconds by 1 if seconds are equal to 60 then increment minute by 1 and set seconds to 0. If minutes become equal to 60 then increment hrs by 1 and set minutes to 0. Write down a method that compares two time objects and return true if they are equal else returns false.

Q5. Create a class Rational having fields (num, denum). Include two argument constructor, get() and print() methods. get() should throw exception if entered denominator is zero. Finally, write an application that uses Rational class. Instantiate two objects and then call get() and display method for each object.

Q6. a) What is Composition? Explain your answer with example. [5]
b) What is this keyword and its purpose. Give an example. [4]

Q7. Write a program that counts the number of times a particular character occurs in a text file. Your program should prompt for the character.