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
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.
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() { }
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 __
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
Q 6 - HAS-A relationship between the classes is shown through.
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() { }
B - Error, as the function is not called.
C - Error, as the function is defined without its declaration
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]; }
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]; }
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; }
Class member variables cannot be initialized.
#include<iostream> using namespace std; main() { class student { int rno = 10; } v; cout<<v.rno; }