Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Chapter 1: Principles of Object Oriented Programming

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which operator in C++ is called the extraction operator and is typically used with cin to read input into a variable?

a)

<< insertion operator for output

b)

>> extraction operator for input

c)

== equality operator for comparison

d)

:: scope resolution for names

2.

Which statement best distinguishes Object-Oriented Programming from Procedure-Oriented Programming regarding data focus and structure?

a)

POP emphasizes data and groups it into objects

b)

OOP emphasizes data and groups it into objects

c)

POP emphasizes objects communicating via methods

d)

OOP emphasizes free data moving across functions

3.

What is data encapsulation in C++?

a)

Showing essential features while hiding details

b)

Binding data and methods within a single unit

c)

Allowing data to move freely between functions

d)

Exposing variables directly for easy access

4.

Which statement best contrasts C and C++ regarding programming paradigms?

a)

C supports object paradigms, C++ supports procedural paradigms

b)

C supports procedural paradigms, C++ supports both paradigms

c)

C supports both paradigms, C++ supports only object paradigms

d)

C supports only object paradigms, C++ supports only procedural paradigms

5.

In C++, which for-loop header correctly iterates an index i from 0 through 4 to print five elements?

a)

for(i=1;i<=5;i++)

b)

for(int i=0;i<5;i++)

c)

for(int i=0;i<=4;i--)

d)

for(i=0;i<=5;i++)

6.

Which statement about the new and delete operators is correct?

a)

new allocates stack memory for variables

b)

delete releases memory allocated with malloc

c)

new returns a base address to a pointer

d)

delete initializes allocated memory to zero

7.

Given A = 60 (0011 1100) and B = 13 (0000 1101) in C++, what is the result of the expression ABA ^ B in decimal?

a)

12

b)

49

c)

61

d)

-61

8.

Which description best fits an if-else statement?

a)

Executes if block on true, else block on false

b)

Executes both blocks in sequence always

c)

Skips both blocks when condition is true

d)

Requires two conditions evaluated sequentially

9.

Given int a = 100; if (a < 20) { cout << "a is less than 20"; } else { cout << "a is not less than 20"; } What prints?

a)

a is not less than 20

b)

a is less than 20

c)

No output is produced

d)

Compilation error occurs

10.

Why does sizeof usually not evaluate its operand at runtime for objects?

a)

Because it is computed at compile time for known types

b)

Because it always calls a memory allocator internally

c)

Because it requires executing the object's constructor

d)

Because it depends on current stack pointer value