0% found this document useful (0 votes)
51 views3 pages

OOP Final Fall'22

The document is a final exam paper for the Object Oriented Programming course at the National University of Computer & Emerging Sciences, Karachi, scheduled for December 19, 2022. It includes instructions for students, a total of 7 questions covering various OOP concepts, and specifies the exam duration and maximum marks. The questions range from multiple-choice to coding tasks involving class design and exception handling.

Uploaded by

k240807
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views3 pages

OOP Final Fall'22

The document is a final exam paper for the Object Oriented Programming course at the National University of Computer & Emerging Sciences, Karachi, scheduled for December 19, 2022. It includes instructions for students, a total of 7 questions covering various OOP concepts, and specifies the exam duration and maximum marks. The questions range from multiple-choice to coding tasks involving class design and exception handling.

Uploaded by

k240807
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

National University of Computer & Emerging Sciences, Karachi

Fall – 2022, School of Computing


Final Exam
19th December 2022, 08:30 am – 11:30 am
Course Code: CS1004 Course Name: Object Oriented Programming
Instructor Name: Dr. Abdul Aziz / Mr. Basit Ali
Student Roll No: Section No:

Instructions:

 Return the question paper and make sure to keep it inside your answer sheet.
 Read questions completely before answering. There are 7 questions, 2 page and 3 sides.
 In case of any ambiguity, you may make assumption. However, your assumption should not
contradict any statement in the question paper.
 You are not allowed to write anything on the question paper (except your ID and section).

Time: 180 minutes. Max Marks: 80 marks

Question 1: MCQs. (5 X 1 = 5 Marks)

1. Which of these features of OOP would indicate code reusability?


a. Polymorphism
b. Abstraction
c. Inheritance
d. Encapsulation
2. If in case, in multiple inheritances, a class R would inherit the Class Q, while Class Q would inherit the
class P, then in which sequence would their destructors be called in case we declare an object of Class R?
a. ~R() then ~P() then ~Q()
b. ~P() then ~Q() then ~R()
c. ~Q() then ~R() then ~P()
d. ~R() then ~Q() then ~P()
3. __________ is the universal handler class for exceptions.
a. Maths
b. Object
c. Exceptions
d. Errors
4. Which of the following definition is incorrect for polymorphism?
A. Polymorphism helps in redefining the same functionality
B. Polymorphism concept is the feature of object-oriented programming (OOP)
C. It always increases the overhead of function definition
D. Ease in the readability of the program
5. Which member of the superclass is never accessible to the subclass?
A. Public member
B. Protected member
C. Private member
D. All of the mentioned

Question 2: (2+2+6 = 10 Marks)

A. What is a virtual function? (2)


B. Differentiate between a virtual function and pointer to function? (2)

1 OF 3
C. create an abstract class Animal that has a function sound (); now create a new class cat and a class
dog that inherited from the Animal class. Now demonstrate a mechanism where we want to call the
sound of cat and dog (both) using a reference of an Animal Instance. (6)

Question 3: (2+4+4 = 10 Marks)

A. What is an Exception. (2)


B. Explain the four ways to deal with any exception. (4)
C. Create a class LoginFailedException that is of user define exception in a program that print an
exception message “Username or Password not matched” when the user is unable to provide proper
credentials. (4)

Question 4: (2+4+4 = 10 Marks)

A. Explain the concept of specialized templates in C++? (2)

class MyVector
{
private:
int *buffer;
MyVector (const MyVector &Var1) { }
public:
int & operator=(const MyVector &Var2) { }
~MyVector () { }
int& operator [ ] (unsigned int index) { }
const int& operator [ ] (unsigned int index) const { }
}

B. Convert the above given class into a Generic Class. (4)


C. Create a specialized template for the above code Question 3 (b) to handle any character type data
and add the following similar functionality in place of operator []. (4)

for(int j = 0; j < 20; j++)


ReceiveMsg(MsgQ[j]);

Question 5: (2+4+4 = 10 Marks)

A. Differentiate between the concepts of Inheritance Vs Friend Class Vs Containership. (2)


B. Explain the types of relationships between the objects in an application. (2)
C. Show a coded example for each of the relationship type. (6)

Question 6: (2.5 X 6 = 15 Marks)

A) Create a Base class called Car. The Car class has the following fields and methods.
 int speed;
 double regularPrice;
 string color;
 double getSalePrice();
B) Create a sub class of Car class and name it as Truck. The Truck class has the following fields and
methods.
 int weight;
 double getSalePrice(); //If weight>2000, 10%discount. Otherwise, 20% discount.

2 OF 3
C) Create a subclass of Car class and name it as Ford. The Ford class has the following fields and
methods.
 int year;
 int manufacturerDiscount;
 double getSalePrice(); //From the sale price computed from Car class, subtract the
manufacturer Discount.
D) Create a subclass of Car class and name it as Sedan. The Sedan class has the following fields and
methods.
 int length;
 double getSalePrice();//Iflength>20feet, 5%discount. Otherwise, 10%discount.
E) Create MyOwnAutoShop class which contains the main() method. Perform the following within the
main() method.
 Create an instance of Sedan class and initialize all the fields with appropriate values. Use
Base class method in the constructor for initializing the fields of the superclass.
 Create two instances of the Ford class and initialize all the fields with appropriate values. Use
Base class method in the constructor for initializing the fields of the super class.
 Create an instance of Car class and initialize all the fields with appropriate values. Display the
sale prices of all instance
F) What if the class Car is an abstract class? What changes will you encounter in your code?

Question 7: (5 X 4 = 20 Marks)

Implement a use case where you have to keep the records and perform statistical analysis for a class of 20
students by adhering the object oriented principles. The information of each student contains ID, Name,
Gender, quizzes Scores (two quizzes per semester), mid-term score, final score, and total score. All the
records must be store in the file and you must read the record from the file in order to perform the given
below analysis:

A) Name of student who scored the maximum score in mid-term.


B) Average score of final exam.
C) Given a user of ID, print all the data of that student on the screen.
D) A functionality to update the record except for the ID, which cannot be change.

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX HAPPY CODING XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

3 OF 3

You might also like