1. Void pointer can point to which type of objects?
a) int
b) float
c) double
d) all of the mentioned
2. When does the void pointer can be dereferenced?
a) when it doesn’t point to any value
b) when it cast to another type of object
c) using delete keyword
d) none of the mentioned
3. The pointer can point to any variable that is not declared with which of these?
a) const
b) volatile
c) both a & b
d) static
4. A void pointer cannot point to which of these?
a) methods in c++
b) class member in c++
c) both a & b
d) none of the mentioned
5. What is the output of this program?
a) abcdef
b) abcdefghij
c) compile time error
d) runtime error
6. What is the output of this program?
a) equal
b) no output
c) compile error
d) runtime error
7. What is the output of this program?
a) 2d
b) two memory addresses
c) both of the mentioned
d) none of the mentioned
8. What is the output of this program?
a) 5
b) 6
c) compile time error
d) runtime error
9. What is the output of this program?
a) 8, memory address
b) 8.14
c) memory address
d) none of the mentioned
10. What we can’t do on a void pointer?
a) pointer arithemetic
b) pointer functions
c) both of the mentioned
d) none of the mentioned
a) int
b) float
c) double
d) all of the mentioned
2. When does the void pointer can be dereferenced?
a) when it doesn’t point to any value
b) when it cast to another type of object
c) using delete keyword
d) none of the mentioned
3. The pointer can point to any variable that is not declared with which of these?
a) const
b) volatile
c) both a & b
d) static
4. A void pointer cannot point to which of these?
a) methods in c++
b) class member in c++
c) both a & b
d) none of the mentioned
5. What is the output of this program?
#include <iostream>
using namespace std;
int func(void *Ptr);
int main()
{
char *Str = "abcdefghij";
func(Str);
return 0;
}
int func(void *Ptr)
{
cout << Ptr;
return 0;
}
b) abcdefghij
c) compile time error
d) runtime error
6. What is the output of this program?
#include <iostream>
using namespace std;
int main()
{
int *p;
void *vp;
if (vp == p);
cout << "equal";
return 0;
}
b) no output
c) compile error
d) runtime error
7. What is the output of this program?
#include <iostream>
using namespace std;
int main()
{
int i;
char c;
void *data;
i = 2;
c = 'd';
data = &i;
cout << "the data points to the integer value" << data;
data = &c;
cout << "the data now points to the character" << data;
return 0;
}
b) two memory addresses
c) both of the mentioned
d) none of the mentioned
8. What is the output of this program?
#include <iostream>
using namespace std;
int main()
{
int n = 5;
void *p = &n;
int *pi = static_cast<int*>(p);
cout << *pi << endl;
return 0;
}
b) 6
c) compile time error
d) runtime error
9. What is the output of this program?
#include <iostream>
using namespace std;
int main()
{
int a = 5, c;
void *p = &a;
double b = 3.14;
p = &b;
c = a + b;
cout << c << 'n' << p;
return 0;
}
b) 8.14
c) memory address
d) none of the mentioned
10. What we can’t do on a void pointer?
a) pointer arithemetic
b) pointer functions
c) both of the mentioned
d) none of the mentioned