OOP - Object Oriented Programming, Past Papers

Object Oriented Programming Msc IT 2nd Term 2017 Past Paper UOS

University of Sargodha M.Sc. 2nd Term Examination 2017 Object Oriented Programming subject IT exam paper with questions on Java programming concepts like polymorphism, inheritance, interfaces, and exception handling.

University of Sargodha

M.Sc. 2nd Term Examination 2017

Subject: Information Technology
Paper: Object Oriented Programming (CMP-2123)

Time Allowed: 2.30 Hours
Maximum Marks: 60

Objective Part (Compulsory)

Q. No.1. Write short answers of the following in 2-3 lines on your answer sheet. (2*12)

i. Differentiate class and an object?
ii. What is JVM?
iii. What is method overriding in Java?
iv. Differentiate an Interface and abstract class?
v. What is Abstraction?
vi. What are packages?
vii. Differences between “this” and “super” keywords?
viii. Can java support multiple inheritance? Justify your answer?
ix. What is runtime polymorphism or dynamic method dispatch?
x. Why StringBuffer is called mutable?
xi. What do you mean by Checked Exceptions?
xii. Difference between “throw” and “throws” keywords in java?

Subjective Part (4*9=36)

Q. No.2 Create a class Employee with instance variable EmpId, EmpName, Empage and decide proper data types and access modifiers for these variables. Define overloaded constructors, getter/setter methods and also override to String() method. Demonstrate this class in your program.

Q. No.3 Create a class called ‘SHAPE’ (should be made an Abstract class) having two instance variable Length (double), Height (double) with appropriate access specifiers and instance method Get Data() to get and assign the values (to length & Height) from the user, it also has an abstract method Display Area() to compute and display the area of the geometrical object. Derive two specific classes ‘TRIANGLE’ and ‘RECTANGLE’ from the base class that override the base class method. Using these three classes design a program that will accept dimension of a triangle / rectangle interactively and display the area.
Hint:
Area of Triangle = ½ (L × h)
Area of Rectangle = L × h

Q. No.4 Explain exception handling in java and why we use nested try blocks. Write a program to demonstrate exception handling by nested try/catch blocks.

Q. No.5 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 to lower method)
ii. Count no. of words in the text (Hint use String split method)

Q. No.6 Write a temperature-conversion application that converts from Fahrenheit to Celsius. The Fahrenheit temperature should be entered from the keyboard (via a JTextField). An uneditable Textfield should be used to display the converted temperature when user clicks on conversion button. Use the following formula for the conversion:
Celsius = 5/9 × (Fahrenheit – 32)

Q. No.7 Explain the advantage of using interfaces in java? Also write a java program to show how a class implements two interfaces.