Question 1
What does the this pointer in C++ represent?
Pointer to class name
Pointer to current object
Pointer to base class
Pointer to constructor
Question 2
#include<iostream>
using namespace std;
class Test
{
static int x;
int *ptr;
int y;
};
int main()
{
Test t;
cout << sizeof(t) << " ";
cout << sizeof(Test *);
}
Question 3
What is the correct way to dynamically create an object in C++?
ClassName obj = new ClassName();
ClassName *obj = new ClassName();
ClassName obj();
ClassName = new object();
Question 4
Which access specifier allows members to be accessed only within the class?
public
protected
private
none of them
Question 5
What will be the size of an empty class in C++?
0
1
4
compile time error
Question 6
Question 7
What will be the output?
class Test {
int x;
};
int main()
{
Test t;
cout << t.x;
return 0;
}
0
Garbage Value
Compiler Error
None of the Above
There are 7 questions to complete.