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

University of Sargodha
BS 2nd Term Examination 2017
Subject: I.T
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 each on your answer sheet. (2*12)
- What are object oriented languages?
- What is difference between structured and object oriented programming?
- What is difference between source code and object code?
- Define the terms class and object?
- What is abstraction?
- What is Encapsulation?
- How many destructors can be defined in a class?
- When would a class destructor be useful?
- When are friend functions necessary?
- What is operator overloading?
- Define inheritance?
- Define polymorphism?
Subjective Part (3 x 16)
Note: Attempt any three out of five questions (All questions carry equal marks)
Q No 2:
Create a class rectangle with attributes length and width, each of which defaults to 1. Provide member function that calculate the area of the rectangle also provide set and get functions for the length and width attributes. The set function should verify that Length and width are each floating point numbers larger than 0.0 and less than 20.0.
Q No 3:
Write a class named operator that have only one data member count the class has the following member functions.
- A constructor to initialize the count.
- Show function to show the count
- Overload ++ operator to increase the count by 1
Q No 4:
Define a class for a bank account that includes the following data members:
- Name of the depositor
- Account number
- Type of Account
- Balance amount in the account
The class also contains the following member functions:
- A constructor to assign initial value
- Deposit function to deposit some amount. It should accept the amount as parameter.
- Withdraw function to withdraw an amount after checking the balance. It should accept the amount as parameter.
- Display function to display name and balance
Q No 5:
Explain constructor overloading with the help of one example.
Q No 6:
Write a class local phone that contains an attribute phone to store a local phone number. The class contains member functions to input and display phone number.
Write a child class NatPhone for national phone numbers that inherits localPhone class. It additionally contains an attribute to store city code. It also contains member function to input and show the city code.
Write another class IntPhone for international phone numbers that inherits NatPhone class. It additionally contains an attribute to store country code. It also contains member functions to input and show the country code.