Q 1 - One of the following is true for an inline function.

A - It executes faster as it is treated as a macro internally

B - It executes faster because it priority is more than normal function

C - It doesn’t executes faster compared to a normal function

D - None of the above holds true for an inline function

Answer : A

Explaination

As inline function gets expanded at the line of call like a macro it executes faster.

Q 2 - The operator used to access member function of a structure using its object.

A - .

B - ->

C - *

D - None of the above.

Answer : A

Explaination

Just the way we use dot (.) operator to access members of the class, in similar it is used to access the members of the structure too.

Q 3 - In the following program f() is overloaded.

void f(int x) {

}

void f(signed x) {

}

main() {

}

A - True

B - False

Answer : B

Explaination

No, as both the functions signature is same.

Q 4 - Class function which is called automatically as soon as the object is created is called as __

A - Constructor

B - Destructor

C - Friend function

D - Inline function.

Answer : A

Explaination

If not provided the same, default constructor from the compiler is called automatically otherwise the programmer’s provided constructor gets called.

Q 5 - What is the full form of RTTI.

A - Runtime type identification

B - Runtime template identification

C - Robust Template Type Inheritance

D - None of the above.

Answer : A

Explaination

Q 6 - HAS-A relationship between the classes is shown through.

A - Inheritance

B - Container classes

C - Polymorphism

D - None of the above.

Answer : B

Explaination

A class containing anther class object as its member is called as container class and exhibits HAS A relationship.

Q 7 - What is the output of the following program?

#include<iostream>

using namespace std;
void f() {
   cout<<"Hello"<<endl;
}
main() {
}

A - No output

B - Error, as the function is not called.

C - Error, as the function is defined without its declaration

D - Error, as the main() function is left empty

Answer : A

Explaination

No output, apart from the option (a) rest of the comments against the options are invalid

#include<iostream>

using namespace std;
void f() {
	cout<<"Hello"<<endl;
}
main() 
{
}

Q 8 - What is the output of the following program?

#include<iostream>

using namespace std;
main() { 
   int a[] = {1, 2}, *p = a;
   
   cout<<p[1]; 
}

A - 1

B - 2

C - Compile error

D - Runtime error

Answer : B

Explaination

as ‘p’ holds the base address then we can access array using ‘p’ just like with ‘a’

#include<iostream>

using namespace std;
main() { 
   int a[] = {1, 2}, *p = a;
   
   cout<<p[1]; 
}

Q 9 - Identify the C++ compiler of Linux

A - cpp

B - g++

C - Borland

D - vc++

Answer : B

Explaination

g++ is GNU C++ compiler for linux. Borland and vc++ (Microsoft visual c++) for windows.

Q 10 - What is the output of the following program?

#include<iostream>

using namespace std;
main() { 
   class student { 
      int rno = 10;
   } v;
  
   cout<<v.rno;
}

A - 10

B - Garbage

C - Runtime error

D - Compile error

Answer : D

Explaination

Class member variables cannot be initialized.

#include<iostream>

using namespace std;
main() { 
   class student { 
      int rno = 10;
   } v;
  
   cout<<v.rno;
}