wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C++ Internal Assessment

Total questions: 40

Worksheet time: 37mins

Name
Class
Date
1.
The process of creating a new variable without value
a)
declaration
b)
naming
c)
instantiation
d)
assigning
2.

Which of the following is a correct comment?

a)

*/ Comments */

b)

** Comment **

c)

/* Comment */

d)

{ Comment }

3.

When a class is derived from a base class it gets access to:

a)

Private

b)

Protected

c)

Private and Protected

d)

Protected and Public

e)

Private, Protected and Public

4.

In a class the access specifiers are _______ by default:

a)

Private

b)

Protected

c)

Public

5.

When class B is inherited from class A, what is the order in which the destructors are called.

a)

Class A first Class B next

b)

Class B first Class A next

c)

Class B's only as it is the child class

d)

Class A's only as it is the parent class

6.

The compiler creates an instance of a function template in memory as soon as it encounters the template.

a)

True

b)

False

7.

There can only be one catch block in a program

a)

True

b)

False

8.

Reg No in full

4 lines
9.

In the following loop construct, which one is executed only once always.

for(exp1; exp2; exp3)

a)

exp1

b)

exp3

c)

exp1 and exp3

d)

exp1,exp2 and exp3

10.

Choose a correct C do while syntax.

a)

dowhile(condition) { //statements }

b)

do while(condition) { //statements }

c)

do { //statements }while(condition)

d)

do { //statements }while(condition);

11.

Loops in C Language are implemented using.?

a)

While Block

b)

For Block

c)

Do While Block

d)

All the above

12.
Integer, float, boolean and char are ...
a)
types of operators
b)
types of functions
c)
types of variables
d)
types of programming languages
13.
After running the following code, what will be the value of x?
y = 3;
x = 5 * y;
a)
3
b)
5
c)
15
d)
0
14.
What is the output of this program?
Program
int main()
{
cout<<"Hi everybody";
return 0;
}
a)
"Hi everybody"
b)
Hi everybody"
c)
Hi everybody
d)
"Hi everybody
15.

Evaluate the following expressions to true or false

5+1==6 || 8-1>4

a)

True

b)

False

16.

Evaluate the following expressions to true or false


5 >= (1+6)-4

a)

True

b)

False

17.

If originally x=2,y=0, and z=1, what is the value of x, y, and z after executing the following code?


if (x>y)


y=x;

else

z=x;

a)

x=2 y=2 z=1

b)

x=0 y=2 z=0

c)

x=2 y=1 z=1

d)

x=2 y=0 z=1

18.

c++ is an _____________ , developed by ______________ , and is an extension of c language

a)

object oriented program , Bjarane

b)

class and data

c)

complier, interpreter

d)

functions comments

19.

the <iostream .h> provides the basic INPUT and output fundamentales

a)

true

b)

false

c)

maybe

20.

When using the ______________,C++ only evaluates what is necessary from left to right to come up with combined reational results,.

a)

logical operaters

b)

compound assignment

c)

associative

21.

Do while loops

a)

Runs a statement once

b)

Runs a statement twice

c)

Runs a statement multiple times or not within a boolean condition

d)

Doesn't run at all

22.

iostream

a)

Displays output from the screen and input from the keyboard

b)

Has all the math equations

c)

Counts the time

d)

Checks if the code has a function

23.

When a class becomes a friend of another class they are additionally getting access to:

a)

Private

b)

Protected

c)

Public

d)

None of the above

24.

There can only be one catch block in a program

a)

True

b)

False

25.

What does the word virtual do when placed in front of a member function in C++?

a)

Forces derived classes to define the function to compile.

b)

Allows derived classes, not required, to define the function.

c)

Does not place the function in text segment if it is not called.

d)

None of the above.

26.

What happens if the word static is placed in front of a member function in C++?

a)

The member function can be called even if we do not create an instance of the class.

b)

It places the member function in the static part of memory

c)

It will cause an error and the program will not compile.

d)

None of the above.

27.

When overloading a function, the signature of the function is determined by:

a)

The name of the function

b)

The name of the function and number of argument and types

c)

The return type, name and number of arguments and types.

28.

What is the difference when allocating the following memory?

int array1[15];

int array2[3][5];

a)

array1 is larger

b)

array2 is larger

c)

The size allocated is the same

29.

What does <= mean?

a)

less than

b)

greater than

c)

less than or equal to

d)

greater than or equal to

30.
Which command moves the shown text to the next line?
a)
\t
b)
\n
c)
\r
d)
\s
31.

Evaluate the following expressions to true or false


3!=4-1

a)

true

b)

False

32.

If originally x=2,y=0, and z=1, what is the value of x, y, and z after executing the following code?


if (x>y)


y=x;

else

z=x;

a)

x=2 y=2 z=1

b)

x=0 y=2 z=0

c)

x=2 y=1 z=1

d)

x=2 y=0 z=1

33.

Write the output of the following program.

#include <iostream>


void X(int &A, int &B)

{ A = A + B;

B = A - B;

A = A - B;

}

int main()

{ int a = 4, b =18;

X(a,b);

cout<< a <<","<< b;

return 0;

}

4 lines
34.

Arrays can be initialized with an initialization list:


int tests[] = {79,82,91,77,84};

a)

True

b)

False

35.

int Grades[12]={78,80,82,84,86,88,90,92,94,96,98,100};


for (int j=0; j<12; j+=12)

cout<<Grades[j]<<" "<<Grades[j+1]<<" "<<Grades[j+2]+10<<" "<<Grades[11] << endl;


What are displayed when you run this program? write them in order!


Ex: 100 80 90

4 lines
36.

The last element's index is n-1 where n is the number of elements in the array.

a)

True

b)

False

37.

Of the following which one is correct to find smallest element in an array?

a)

lowest = numbers[0];

for (count = 1; count < SIZE; count++)

{ if (numbers[count] != lowest) lowest = numbers[count]; }

b)

lowest = numbers[0];

for (count = 1; count < SIZE; count++)

{ if (numbers[count] == lowest) lowest = numbers[count]; }

c)

lowest = numbers[0];

for (count = 1; count < SIZE; count++)

{ if (numbers[count] > lowest) lowest = numbers[count]; }

d)

lowest = numbers[0];

for (count = 1; count < SIZE; count++)

{ if (numbers[count] < lowest) lowest = numbers[count]; }

38.
main(){ int i=1,j; j=i++; cout<<i<<j; } Output of program
a)
i=1,j=1
b)
i=2,j=2
c)
i=1,j=2
d)
i=2,j=1
39.

int a=0,b=1,c=-1;

float p =2.5,q=0.0; what will be the value of

(a<b)&&(c<b)

a<b || c<b

!a

(a)  

40.

what is the output of the program

# include<iostream.h>

int a= 20;

void main()

{int a= 10;

cout<<a;

cout<<::a;

}

(a)