wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C++ Object-Oriented Programming Quiz

Total questions: 55

Worksheet time: 28mins

Name
Class
Date
1.

Which feature of OOP allows the same function name to have different implementations?

a)

Abstraction

b)

Polymorphism

c)

Encapsulation

d)

Inheritance

2.

Which C++ feature helps avoid code duplication?

a)

Inheritance

b)

Virtual functions

c)

Operator overloading

d)

Destructors

3.

Which of these is used to free memory allocated with new?

a)

free()

b)

delete

c)

remove()

d)

clear()

4.

Which of these concepts binds code and data together?

a)

Polymorphism

b)

Encapsulation

c)

Abstraction

d)

Overloading

5.

The process of defining more than one function with the same name but different parameters is called:

a)

Function overriding

b)

Function overloading

c)

Operator overloading

d)

Inheritance

6.

Which of the following supports runtime polymorphism?

a)

Virtual functions

b)

Function overloading

c)

Operator overloading

d)

Inline functions

7.

Virtual functions are declared using:

a)

virtual keyword

b)

dynamic keyword

c)

override keyword

d)

polymorphic keyword

8.

Which type of binding is used in virtual functions?

a)

Early binding

b)

Late binding

c)

Static binding

d)

Compile-time binding

9.

Function overriding requires:

a)

Same name, different parameters

b)

Same name, same parameters, and inheritance

c)

Same name, different return type

d)

None

10.

If a base class pointer points to a derived class object and the function is virtual:

a)

Base version is called

b)

Derived version is called

c)

Random

d)

Error

11.

Which keyword is used in the derived class to ensure overriding?

a)

override (in modern C++)

b)

virtual

c)

polymorph

d)

extends

12.

Which of the following is not a type of inheritance in C++?

a)

Single

b)

Multiple

c)

Multilevel

d)

Parallel

13.

Protected members are accessible in:

a)

Same class only

b)

Derived classes and same class

c)

Outside the class directly

d)

None

14.

Which access mode makes base class members private in derived class?

a)

public

b)

protected

c)

private

d)

default

15.

Constructors of base class are called:

a)

After derived class constructor

b)

Before derived class constructor

c)

Randomly

d)

Not at all

16.

Which keyword is used for inheritance in C++?

a)

extends

b)

:

c)

implements

d)

->

17.

Which inheritance allows a class to be derived from more than one base class?

a)

Single

b)

Multiple

c)

Hierarchical

d)

Multilevel

18.

In multiple inheritance, if two base classes have the same function name, which is used?

a)

First base class

b)

Last base class

c)

Depends on scope resolution operator

d)

Random

19.

Which of these is true about constructors in derived classes?

a)

Base constructor is always called first

b)

Derived constructor is always called first

c)

Order is undefined

d)

No constructor is called

20.

Operator overloading is used to:

a)

Define new operators

b)

Change how existing operators work for objects

c)

Create new keywords

d)

None of the above

21.

Which operator cannot be overloaded?

a)

+

b)

=

c)

::

d)

[]

22.

Unary operator overloading usually takes:

a)

No parameters for member function

b)

One parameter for non-member function

c)

Both a and b

d)

Two parameters always

23.

Which type of polymorphism does operator overloading support?

a)

Compile-time

b)

Run-time

c)

Both

d)

None

24.

Function overloading is resolved at:

a)

Compile-time

b)

Run-time

c)

Link-time

d)

Preprocessing

25.

Which is correct for overloading binary operators as member functions?

a)

They take one argument

b)

They take two arguments

c)

They take no arguments

d)

Only static

26.

A constructor has the same name as:

a)

The class

b)

The file

c)

The first member variable

d)

None

27.

Which of these is not a type of constructor?

a)

Default

b)

Parameterized

c)

Copy

d)

Virtual

28.

Which constructor is called when an object is created without arguments?

a)

Default

b)

Parameterized

c)

Copy

d)

Destructor

29.

A destructor is declared using:

a)

~ClassName()

b)

#ClassName()

c)

delete ClassName()

d)

free ClassName()

30.

Can a constructor be overloaded?

a)

Yes

b)

No

c)

Only default constructor

d)

Only parameterized constructor

31.

The copy constructor is called when:

a)

An object is copied to another

b)

An object is destroyed

c)

A class is declared

d)

A variable is assigned

32.

Which of the following is true about destructors?

a)

They take arguments

b)

They return values

c)

They cannot be overloaded

d)

They can be virtual only in base classes

33.

Which keyword is used to define a class in C++?

a)

struct

b)

class

c)

object

d)

define

34.

Which of the following is not an access specifier in C++?

a)

public

b)

private

c)

protected

d)

friend

35.

Members declared as private are accessible:

a)

Only within the class

b)

From any function

c)

From derived classes only

d)

From main function directly

36.

Objects are instances of:

a)

Functions

b)

Classes

c)

Arrays

d)

Variables

37.

Which of the following can be declared inside a class?

a)

Variables

b)

Functions

c)

Constructors

d)

All of the above

38.

The keyword this in C++ refers to:

a)

Current function name

b)

Current object pointer

c)

Class name

d)

Parent class

39.

What is the default access specifier for members of a class in C++?

a)

public

b)

private

c)

protected

d)

None

40.

What happens if a class has no access specifier?

a)

Members are private

b)

Members are public

c)

Compiler error

d)

They become protected

41.

Which feature allows a function in C++ to have default arguments?

a)

Function overloading

b)

Function overriding

c)

Default parameters

d)

None of the above

42.

What happens if more than one function has the same name but different parameters?

a)

Error occurs

b)

Function overloading

c)

Function overriding

d)

Polymorphism only at runtime

43.

Which is correct about function overloading in C++?

a)

It is done at runtime

b)

It is done at compile time

c)

It requires inheritance

d)

It is same as overriding

44.

Can default arguments be skipped in the middle of a parameter list?

a)

Yes

b)

No

c)

Only if it’s a pointer

d)

Depends on compiler

45.

Which of the following supports compile-time polymorphism?

a)

Virtual functions

b)

Function overloading

c)

Function overriding

d)

Dynamic binding

46.

Which of these is the correct syntax to take input in C++?

a)

cin >> variable;

b)

scanf("%d", &variable);

c)

input variable;

d)

read(variable);

47.

Which operator is used for insertion (output) in C++?

a)

>

b)

<

c)

::

d)

->

48.

What is the default value of a local variable in C++?

a)

0

b)

NULL

c)

Undefined/garbage value

d)

-1

49.

Which of the following is a valid C++ data type?

a)

int

b)

float

c)

bool

d)

All of the above

50.

In C++, which keyword is used to define a constant value?

a)

final

b)

const

c)

define

d)

fixed

51.

Which of the following best describes Object-Oriented Programming?

a)

Programming based on functions only

b)

Programming organized around data and objects

c)

Programming without classes

d)

Programming using only loops

52.

Which of these is not a feature of OOP?

a)

Encapsulation

b)

Abstraction

c)

Inheritance

d)

Assembly language

53.

What is the main difference between OOP and procedural programming?

a)

OOP focuses on objects, procedural focuses on functions

b)

OOP uses only loops, procedural uses only recursion

c)

OOP is slower

d)

Procedural programming has no variables

54.

In OOP, encapsulation means:

a)

Combining data and functions into a single unit

b)

Hiding implementation details

c)

Inheriting properties from another class

d)

Writing all functions in one file

55.

Abstraction in OOP refers to:

a)

Hiding implementation and showing only essential details

b)

Making functions public

c)

Using operators in classes

d)

Writing shorter code