wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Quiz-1-Set-1-OOPs-CPP

Total questions: 20

Worksheet time: 20mins

Name
Class
Date
1.
What does "C++" represent in the name of the language?
a)
Class++
b)
C version 2
c)
Increment operator (++), symbolizing evolution
d)
C with pointers
2.
Which operator is used with cout for output?
a)
&&
b)
>>
c)
<<
d)
->
3.
The keyword endl in C++ is used to:
a)
End the program
b)
Exit a loop
c)
Close the file
d)
Insert newline and flush buffer
4.
Which of the following is NOT a valid data type in C++?
a)
signed char
b)
long double
c)
short int
d)
unsigned float
5.
What is the use of setw() in C++?
a)
Swap two variables
b)
Write to file
c)
Set environment variable
d)
Set width for output formatting
6.
What is the keyword used for decision making in C++?
a)
All of the above
b)
switch
c)
if
d)
else
7.
Which is the correct way to declare an array in C++?
a)
int array(5);
b)
int array[5];
c)
array int[5];
d)
int[5] array;
8.
Which construct is used to run code at least once regardless of condition?
a)
for
b)
do-while
c)
while
d)
if-else
9.
What is the output of swapping via pointer if a=10, b=20?
a)
Error
b)
Garbage values
c)
a=10, b=20
d)
a=20, b=10
10.
Which keyword is used to create a function pointer?
a)
pointer
b)
*
c)
link
d)
ref
11.
What is the output of `switch(num)` if `num = 25`? (cases: 10, 20, 30)
a)
It is 10
b)
Not 10, 20 or 30
c)
Compilation error
d)
It is 25
12.
What is the output of the following array? int arr[5]={10,0,20,0,30};
a)
10 0 20 0 30
b)
0 0 0 0 0
c)
Compilation Error
d)
10 20 30
13.
Which operator is used to access members of a class in C++?
a)
Both . and ->
b)
:
c)
->
d)
.
14.
What is the purpose of the `break` statement in a loop?
a)
Skip the current iteration
b)
Pause the loop execution
c)
Continue to the next iteration
d)
Exit the loop immediately
15.
What does the `sizeof` operator return in C++?
a)
Size of an array
b)
Size of a function
c)
Size of a data type in bits
d)
Size of a variable in bytes
16.
Which of the following is a valid way to create a pointer in C++?
a)
int ptr*;
b)
int *ptr;
c)
int &ptr;
d)
ptr int*;
17.
Which of the following is used to allocate memory dynamically in C++?
a)
calloc
b)
malloc
c)
new
d)
alloc
18.

Which of the following statements about constructors in C++ is true?

a)

A constructor can return values like normal functions

b)

A constructor must always have the same name as the class

c)

A constructor can be declared as virtual.

d)

A constructor can be called explicitly like a normal function.

19.
What is the output of cout << sizeof(int); assuming a 2-byte int?
a)
2
b)
4
c)
10
d)
8
20.

Which of the following is NOT a feature of C++?

a)

Object-oriented

b)

Function overloading

c)

Garbage collection

d)

Exception handling