Font size
WorksheetsC++ Internal Assessment
Total questions: 40
Worksheet time: 37mins
Which of the following is a correct comment?
*/ Comments */
** Comment **
/* Comment */
{ Comment }
When a class is derived from a base class it gets access to:
Private
Protected
Private and Protected
Protected and Public
Private, Protected and Public
In a class the access specifiers are _______ by default:
Private
Protected
Public
When class B is inherited from class A, what is the order in which the destructors are called.
Class A first Class B next
Class B first Class A next
Class B's only as it is the child class
Class A's only as it is the parent class
The compiler creates an instance of a function template in memory as soon as it encounters the template.
True
False
There can only be one catch block in a program
True
False
Reg No in full
In the following loop construct, which one is executed only once always.
for(exp1; exp2; exp3)
exp1
exp3
exp1 and exp3
exp1,exp2 and exp3
Choose a correct C do while syntax.
dowhile(condition) { //statements }
do while(condition) { //statements }
do { //statements }while(condition)
do { //statements }while(condition);
Loops in C Language are implemented using.?
While Block
For Block
Do While Block
All the above
y = 3;
x = 5 * y;
Program
int main()
{
cout<<"Hi everybody";
return 0;
}
Evaluate the following expressions to true or false
5+1==6 || 8-1>4
True
False
Evaluate the following expressions to true or false
5 >= (1+6)-4
True
False
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;
x=2 y=2 z=1
x=0 y=2 z=0
x=2 y=1 z=1
x=2 y=0 z=1
c++ is an _____________ , developed by ______________ , and is an extension of c language
object oriented program , Bjarane
class and data
complier, interpreter
functions comments
the <iostream .h> provides the basic INPUT and output fundamentales
true
false
maybe
When using the ______________,C++ only evaluates what is necessary from left to right to come up with combined reational results,.
logical operaters
compound assignment
associative
Do while loops
Runs a statement once
Runs a statement twice
Runs a statement multiple times or not within a boolean condition
Doesn't run at all
iostream
Displays output from the screen and input from the keyboard
Has all the math equations
Counts the time
Checks if the code has a function
When a class becomes a friend of another class they are additionally getting access to:
Private
Protected
Public
None of the above
There can only be one catch block in a program
True
False
What does the word virtual do when placed in front of a member function in C++?
Forces derived classes to define the function to compile.
Allows derived classes, not required, to define the function.
Does not place the function in text segment if it is not called.
None of the above.
What happens if the word static is placed in front of a member function in C++?
The member function can be called even if we do not create an instance of the class.
It places the member function in the static part of memory
It will cause an error and the program will not compile.
None of the above.
When overloading a function, the signature of the function is determined by:
The name of the function
The name of the function and number of argument and types
The return type, name and number of arguments and types.
What is the difference when allocating the following memory?
int array1[15];
int array2[3][5];
array1 is larger
array2 is larger
The size allocated is the same
What does <= mean?
less than
greater than
less than or equal to
greater than or equal to
Evaluate the following expressions to true or false
3!=4-1
true
False
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;
x=2 y=2 z=1
x=0 y=2 z=0
x=2 y=1 z=1
x=2 y=0 z=1
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;
}
Arrays can be initialized with an initialization list:
int tests[] = {79,82,91,77,84};
True
False
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
The last element's index is n-1 where n is the number of elements in the array.
True
False
Of the following which one is correct to find smallest element in an array?
lowest = numbers[0];
for (count = 1; count < SIZE; count++)
{ if (numbers[count] != lowest) lowest = numbers[count]; }
lowest = numbers[0];
for (count = 1; count < SIZE; count++)
{ if (numbers[count] == lowest) lowest = numbers[count]; }
lowest = numbers[0];
for (count = 1; count < SIZE; count++)
{ if (numbers[count] > lowest) lowest = numbers[count]; }
lowest = numbers[0];
for (count = 1; count < SIZE; count++)
{ if (numbers[count] < lowest) lowest = numbers[count]; }
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)
what is the output of the program
# include<iostream.h>
int a= 20;
void main()
{int a= 10;
cout<<a;
cout<<::a;
}
(a)
