OOP Final Fall'22
OOP Final Fall'22
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).
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)
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 { }
}
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:
3 OF 3