wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Day 15 Assessment -Encapsulation & Abstraction, Exception-28June

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is encapsulation in C++?

a)

Hiding the internal details and showing only the functionality

b)

Creating multiple functions with the same name

c)

Inheriting properties from another class

d)

Allocating memory for objects

2.

How can you achieve encapsulation in C++?

a)

By using classes and access specifiers

b)

By using only global variables

c)

By writing functions outside of classes

d)

By using pointers

3.

Which access specifier restricts access to the members of a class only to functions within the same class?

a)

public

b)

protected

c)

private

d)

static

4.

What is abstraction in C++?

a)

Using derived classes to extend base class functionality

b)

Providing only essential information and hiding the background details

c)

Allocating dynamic memory for objects

d)

Overloading operators to work with user-defined data types

5.

How is abstraction typically implemented in C++?

a)

Through the use of access specifiers

b)

By using abstract classes and interfaces

c)

By allocating memory dynamically

d)

Through the use of global variables

6.

What is the purpose of exception handling in C++?

a)

To write efficient code

b)

To handle runtime errors gracefully

c)

To manage memory allocation

d)

To create multiple threads

7.

Which keyword is used to throw an exception in C++?

a)

catch

b)

throw

c)

try

d)

finally

8.

Which block is used to handle exceptions in C++?

a)

try

b)

catch

c)

finally

d)

throw

9.

What will happen if an exception is thrown but not caught in C++?

a)

The program will terminate abruptly

b)

The exception will be ignored

c)

The program will enter an infinite loop

d)

The exception will be automatically handled by the system

10.

What does the what() member function of the exception class do?

a)

Returns a string describing the error

b)

Terminates the program

c)

Rethrows the exception

d)

Catches the exception