Dereferencing

1

Pick out the correct statement.

A. The NULL pointer dereference occurs where a pointer that is expected to be a valid address but instead is equal to NULL.
B. The NULL pointer dereference occurs where a pointer that is expected to be a valid address but instead is equal to memory address.
C. both a & b
D. none of the mentioned

2

What does the dereference operator will return?

A. rvalue equivalent to the value at the pointer address.
B. lvalue equivalent to the value at the pointer address.
C. it will return nothing
D. none of the mentioned

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 << *p << endl;   
8.
        cout << arr << endl;  
9.
        cout << *(arr+3) << endl;
10.
        cout << *(arr) << endl; 
11.
        cout << *arr+9 << endl; 
12.
        return 0;
13.
    }

a) 7

0xbf99fc98

8

5

14

b) 7

8

0xbf99fc98

5

14

c) 0xbf99fc98

d) none of the mentioned


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 << sizeof(p);
8.
        return 0;
9.
    }
A. 4
B. 2
C. Depends on compiler
D. none of the mentioned

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 << a << "\n";
12.
        cout << *ptr_b << "\n";
13.
        cout << *ptr_c << "\n";
14.
        cout << **ptr_c << "\n";
15.
        return 0;
16.
    }

a) 1

1

0xbffc9924

1

b) 1

1

1

0xbffc9924

c) 1

0xbffc9924

1

1

d) none of the mentioned