0% found this document useful (0 votes)
112 views4 pages

C++ Class and Inheritance Quiz

Uploaded by

y805170
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)
112 views4 pages

C++ Class and Inheritance Quiz

Uploaded by

y805170
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

1- which of the following access specifies is used in a class definition by default?

(A) Protected (B) Public (C) Private (D) Friend

2- an expression A.B in c++ means ………

(A) A is a member of object B (B) B is a member of object A

(C) Product of A and B (D) None of these

3- Passing argument be means of making a copy of the variable’s content known as


passing by:

(A) value (B) name (C) reference (D) inheritance

4- which of the following statements are correct when a class is inherited privately?

(A) Public members of the base class become protected members of


the derived class

(B) Public members of the base class become private members of the
derived class

(C) private members of the base class become private members of the
derived class

(D) Public members of the base class become public members of the
derived class

5- which of the following statements are correct for static member function?

i- it can access only other static members of its class


ii- it can be called using the class name, instead of the object

(A) only i correct (B) only ii is correct

(C) both I , ii are correct (D) both I , ii are incorrect


6- if a class is named Job, what must the destructor be named?

(A) _Job (B) ::Job (C) ^Job (D) none of the above

7- which operator allocates storage of the proper size for an object at execution time?

(A) init (B) create (C) new (D) allocate

8- which function is used to change the values of private data members of a class?

(A) mutator (B) constructor (C) accessor (D) none of


above

9 -which of the following is true?

(A) The delete operator destroys a dynamically allocated object

(B) a reference is a pointer

(C) a constructor can have a return type

(D) none of the above

10- an exception is caused by?

(A) Hardware problem (B) problem in the operating system

(C) syntax error (D) run-time error

11- which of the following means “the use of an object of one class in the definition of
another class”?

(A) Encapsulation (B) inheritance (C) composition (D)


abstraction

12- given a class named Book, which of the following is not a valid constructor?

(A) Book(){} (B) Book(Book B){} (C) Book(Book &B){}


(D) Book(char ”[Link]” title){}

13- the major goal of inheritance in c++ is:

(A) To facilitate the conversion of data types

(B) to help modular programming

(C) To extend the capabilities of a class

(D) to hide the details of the base class

14- When an object goes out of the scope, which function is called automatically?

(A) constructor (B) destructor (C) inline (D) none of the above

15- which type of function among the following shows polymorphism?

(A) Inline function (B) virtual function (C) undefined function

(D) class member functions

16- which among the following is the proper syntax for the template class?

(A) template T named(T x , T y){} (B) Template T1(T1 x , T2 y){}

(C) template; (D) Template;

17- which of the following features of OOP is used to derive a class from another ?

(A) Encapsulation (B) Polymorphism (C) data hiding (D) inheritance

18- passing arguments to a destructor or specifying return type to constructor causes?

(A) Logical error (B) syntax error (C) run time error (D) fatal error

19- information hiding can be achieved through ……..

(A) Encapsulation, abstraction (B) encapsulation, polymorphism

(C) Encapsulation, inheritance (D) overloading

20- which is known as a generic class?


(A) Abstract class (B) final class (C) efficient class (D) template class

21- pick out correct statement

(A) A friend function may be a member of another class


(B) A friend function may not be a member of another class
(C) A friend function may or not may be a member of another class
(D) None of the mentioned

22- which inheritance type is used in the class given below? class A : public X , public y{}

(A) Multilevel (B) multiple (C) hybrid (D) hierarchical

23- a template is ……….

(A) A formula creating a generic class (B) used to manipulate the class

(C) used for creating the attributes (D)none of the mentioned

24- ……. Comments begin with //.

(A) Single line (B) two line (C) three line (D) multi-line

25- each variable in an array must have the same …….. as the others.

(A) subscript (B) value (C) data type (D) memory location

26-……. Can be used to initialize an object of the class when the object is created.

(A) subscript (B) inheritance (C) constructor (D)


instantiation

27-……. In form of reuse in which a class can have objects of other classes as member.

(A) encapsulation (B) Data hiding (C) Inheritance (D) composition

You might also like