Sail E0 Webinar

MCQs

Total Questions : 10
Question 1.

Pick out the correct statement.


  1.    The NULL pointer dereference occurs where a pointer that is expected to be a valid address but instead is equal to NULL.
  2.    The NULL pointer dereference occurs where a pointer that is expected to be a valid address but instead is equal to memory address.
  3.    both a & b
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> The NULL pointer dereference occurs where a pointer that is expected to be a valid address but instead is equal to NULL.

None.


Question 2.

What does the dereference operator will return?


  1.    rvalue equivalent to the value at the pointer address.
  2.    lvalue equivalent to the value at the pointer address.
  3.    it will return nothing
  4.    none of the mentioned
 Discuss Question
Answer: Option B. -> lvalue equivalent to the value at the pointer address.

It operates on a pointer variable, and returns an l-value equivalent to the value at the pointer address.


Question 3.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
double arr[] = {5.0, 6.0, 7.0, 8.0};
6.
double *p = (arr+2);
7.
cout
  1.    rvalue equivalent to the value at the pointer address.
  2.    lvalue equivalent to the value at the pointer address.
  3.    it will return nothing
  4.    none of the mentioned
 Discuss Question
Answer: Option B. -> lvalue equivalent to the value at the pointer address.

Answer:(a)
Explanation:
In this program, We are printing the values that are pointed by pointer and also the dereference oerator.
Output:
$ g++ def5.cpp
$ a.out
7
0xbf99fc98
8
5
14


Question 4.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int x = 9;
6.
int* p = &x;
7.
cout
  1.    4
  2.    2
  3.    Depends on compiler
  4.    none of the mentioned
 Discuss Question
Answer: Option C. -> Depends on compiler

The size of a datatype mainly depends on complier only.
Output:
$ g++ def3.cpp
$ a.out
4


Question 5.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main ()
4.
{
5.
int a;
6.
int * ptr_b;
7.
int ** ptr_c;
8.
a = 1;
9.
ptr_b = &a;
10.
ptr_c = &ptr_b;
11.
cout
  1.    4
  2.    2
  3.    Depends on compiler
  4.    none of the mentioned
 Discuss Question
Answer: Option C. -> Depends on compiler

Answer: (a)
Explanation:
In this program, We are printing the values and memory address
by using the pointer and derefernce operator.
Output:
$ g++ def2.cpp
$ a.out
1
1
0xbffc9924
1


Question 6.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int x;
6.
int *p;
7.
x = 5;
8.
p = &x;
9.
cout
  1.    5
  2.    10
  3.    memory address
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> 5

In this program, we are copying the memory location of x into p and then printing the value in 

the address.
Output:
$ g++ def1.cpp
$ a.out
5


Question 7.

Pick out the correct option.


  1.    References automatically dereference without needing an extra character.
  2.    References automatically dereference with an extra character.
  3.    Reference will not dereference
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> References automatically dereference without needing an extra character.

None.


Question 8.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int a, b;
6.
int* c;
7.
c = &a;
8.
a = 200;
9.
b = 200;
10.
*c = 100;
11.
b = *c;
12.
cout
  1.    100 200
  2.    100 0
  3.    200 200
  4.    100 100
 Discuss Question
Answer: Option D. -> 100 100

In this program, We are making the assignments and invoking the both b and c values as 100 

by dereference operator.
Output:
$ g++ def.cpp
$ a.out
100 100


Question 9.

Which is used to tell the COMPUTER that where a pointer is pointing to?


  1.    dereference
  2.    reference
  3.    heap operations
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> dereference

None.


Question 10.

Which is used to do the dereferencing?


  1.    pointer without asterix
  2.    value without asterix
  3.    pointer with asterix
  4.    value with asterix
 Discuss Question
Answer: Option C. -> pointer with asterix

Derefencing is using a pointer with asterix. For example, *(abc).


Latest Videos

Latest Test Papers