OOP (Object-oriented programming) MCQs

OOP (Object-oriented programming) MCQs

The following OOP (Object-oriented programming) MCQs have been compiled by our experts through research, in order to test your knowledge of the subject of OOP (Object-oriented programming). We encourage you to answer these 20 multiple-choice questions to assess your proficiency.
Please continue by scrolling down.

1: Which of the following is true for package access modifier?

A.   The Class which has a Public Modifier can be accessed by all the classes from the particular package and also from different packages

B.   The class which has private as the modifier cannot be accessed by any class even with in the package

C.   The class which has private as the modifier cannot be accessed by any class even with in the package

D.   The Class which has a Public Modifier can be accessed by all the classes from the particular package and also from different packages And The class which has private as the modifier cannot be accessed by any class even with in the package

2: What is dynamic dispatch?

A.   When the function to be executed in response to a function call is determined at the end of the function call

B.   When the function to be executed in response to a function call is determined at run-time

C.   None

D.   When the function to be executed in response to a function call is determined at compile-time

3: Constructors have to be called before the main function:

A.   True

B.   False

4: In dynamic type case a type safety check is incurred at ____________.

A.   Run time

B.   Compile time

5: Constructors never have an explicit return type.

A.   False

B.   True

6: A recursive function would result in infinite recursion, if the following were left out:

A.   Subtraction

B.   Base call

C.   Recursive call

D.   Local variable declarations

7: What are the major elements in an object model?

A.   Abstraction, Encapsulation and persistence

B.   Typing

C.   Hierarchy, concurrency and typing

D.   Abstraction, encapsulation and hierarchy

8: Common behavior can be defined in a superclass and inherited into a subclass using the ___________ keyword.

A.   Inherits

B.   Extend

C.   Extends

D.   Inherit

9: Which of the following is false for a destructor?

A.   The destructor has the same name as the class

B.   If the object was created with a new expression, then its destructor is called when the delete operator is applied to a pointer to the object

C.   Its main purpose is to clean up and to free the resources

D.   None

10: __________ allows for the separation of object interactions from classes and inheritance into distinct layers of abstraction.

A.   Decoupling

B.   Detaching

C.   Loosening

D.   Dispatching

11: If the child object can exist beyond the lifetime of its parent, then the relationship is ____________.

A.   None

B.   Composition

C.   Generalization

D.   Aggregation

12: What is a “const member function”?

A.   None

B.   It means the function is only a read-only function

C.   One which always returns the same values, given the same arguments

D.   Used for constructor and destructor

13: _____________ is actually a parameterized constructor which takes some parameters in order to create instance of a class.

A.   Explicit constructor

B.   Parameterized constructor

C.   Implicit constructor

D.   Virtual constructor

14: Can I create new operators using operator overloading?

A.   No

B.   Yes

15: Can I inherit the constructor and destructor of a base class?

A.   Yes

B.   No

16: A class is a(n) _____________ that is defined by the programmer.

A.   Attribute

B.   Data type

C.   Method

D.   Function

17: Every event object has the _____ method that returns the object that triggered the event.

A.   GetSource()

B.   GetActionCommand()

C.   GetTimeStamp()

D.   GetWhen()

E.   GetKeyChar().

18: Objects are created from abstract data types that encapsulate ________ and ________ together.

A.   Constructor, created

B.   Dot operator.

C.   Subscripts

D.   Data, functions

19: The ________ is used to protect important data.

A.   Private and public

B.   Private access specifier

C.   Destructor function

D.   In their own header files

20: Each object of a class has its own copy of the class's ________.

A.   Member functions

B.   Member variables

C.   Constructor and destructor functions

D.   All of these

E.   None of these