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

Midterm Fall 2021 - Objective - MOCK For Summer

Uploaded by

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

Midterm Fall 2021 - Objective - MOCK For Summer

Uploaded by

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

CE-113 Object Oriented Programming Fall 2021

INSTRUCTORS SOLUTION
Air University
Mid Term Examination: Fall 2021
Subject: CE-113 Object Oriented Programming Total Marks: 20
Date: Monday 8th November, 2021 Time Allowed: 25 mins
Course Instructor: Maham Javed, Saba Mumtaz Semester: BEEP, BEEE, BEET -3 B
Name: Reg Number:
Special Instructions:
1. This is a closed book examination. It contains 04 questions spanned over 02 pages.
2. Multiple answers for same question will be considered wrong.
Question # 01: [CLO 01] Marks: 5
Select the correct answer from the following multiple choice questions.

1. Which of the following is not true for constructors?


a. Its name must be same as that of the class
b. It must not have any return type
c. It must contain a definition body
d. It can contain arguments
2. What is the default access specifier for data members and functions declared within a
class without any specifier, in C++?
a. Private
b. Protected
c. Public
d. Depends on the compiler
3. What best describes constructor overloading?
a. Defining one constructor in each class of a program
b. Defining more than one constructor in a single class
c. Defining more than one constructor in a single class with a different signature
d. Defining a destructor with each constructor
4. If class A is derived from class B which is then derived from class C, which class is the
most specialized and generalized?
a. B is most generalized and specialized
b. A is most generalized and C is most specialized
c. A is most specialized and C is most generalized
d. None of the above
5. What happens if non static members are used in static member functions?
a. Compile time error
b. Executes fine
c. Executes if that member function is not used

Page 1 of 3
CE-113 Object Oriented Programming Fall 2021

d. None of the above

Question # 02: [CLO 01] Marks: 5


State if each of the following statements are true or false.
1. Operator overloading is used to allocate additional function to a predefined operator.
(T)
2. A class is a programmer-defined data type. (T)
3. It is compulsory for all member functions to be public and all data members to be
private. (F)
4. Irrespective of type of derivation private members of a base class are never accessible in
derived classes (T)
5. Every C++ class has a default copy constructor. (T)

Question # 03: [CLO 01] Marks:5


Write the output of the following code:

class Exam{ OUTPUT:


string name; Default Constructor
public: Default Constructor
Exam(){
name = “English”;
Parameterised Constructor
cout<<"Default Destructor for Physics
constructor"<<endl; Destructor for English
} Destructor for English
Exam(string n){
name =n;
cout<<"Parameterized
constructor"<<endl;
}
~Exam(){
cout<<"Destructor for
"<<name<<endl;
}
};
int main(){
Exam e1[2], e2("Physics");
return 0;
}

Question # 04: [CLO 01] Marks:5


What are three access modifiers in C++? Name them and explain their accessibility.

Solution

Public, private, protected (2 marks for all three, 1.5 for two, and 1 for one)
Public members can be accessed anywhere i.e., inside or outside the class. (1)
Private members can be accessed inside the class only (1)

Page 2 of 3
CE-113 Object Oriented Programming Fall 2021

Protected members can be accessed inside the class as well as in the child class. (1)

Page 3 of 3

You might also like