Topic: Chapter 14: Classes and objects (Test 1)



Topic: Chapter 14: Classes and objects
Q.1
The variables declared inside the class are known as data members and the functions are known as
A. data functions
B. inline functions
C. member functions
D. attributes
Answer : Option C
Explaination / Solution:
No Explaination.


Workspace
Report
Q.2

Which of the following statements about member functions are True or False?

i) A member function can call another member function directly with using the dot operator.

ii) Member function can access the private data of the class.
A. i-True, ii-True
B. i-False, ii-True
C. i-True, ii-False
D. i-False, ii-False
Answer : Option B
Explaination / Solution:
No Explaination.


Workspace
Report
Q.3
A member function can call another member function directly, without using the dot operator called as
A. sub function
B. sub member
C. nesting of member function
D. sibling of member function
Answer : Option C
Explaination / Solution:
No Explaination.


Workspace
Report
Q.4
The member function defined within the class behave like
A. inline functions
B. Non inline function
C. Outline function
D. Data function
Answer : Option A
Explaination / Solution:
No Explaination.


Workspace
Report
Q.5
Which of the following access specifier protects data from inadvertent modifications?
A. Private
B. Protected
C. Public
D. Global
Answer : Option A
Explaination / Solution:
No Explaination.


Workspace
Report
Q.6

 class x

{

int y;

 public:

 x(int z){y=z;}

 } x1[4];

int main()

{ x x2(10); return 0;}

How many objects are created for the above program

A. 10
B. 14
C. 5
D. 2
Answer : Option B
Explaination / Solution:
No Explaination.


Workspace
Report
Q.7

State whether the following statements about the constructor are True or False.

i) constructors should be declared in the private section.

ii) constructors are invoked automatically when the objects are created.

A. True, True
B. True, False
C. False, True
D. False, False
Answer : Option C
Explaination / Solution:
No Explaination.


Workspace
Report
Q.8

Which of the following constructor is executed for the following prototype ?

add display( add &); // add is a class name 248
A. Default constructor
B. Parameterized constructor
C. Copy constructor
D. Non Parameterized constructor
Answer : Option C
Explaination / Solution:
No Explaination.


Workspace
Report
Q.9
What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero-argument constructor?
A. Compile-time error
B. Domain error
C. Runtime error
D. Runtime exception.
Answer : Option A
Explaination / Solution:
No Explaination.


Workspace
Report
Q.10
Which of the following create a temporary instance?
A. Implicit call to the constructor
B. Explicit call to the constructor
C. Implicit call to the destructor
D. Explicit call to the destructor
Answer : Option B
Explaination / Solution:
No Explaination.


Workspace
Report