Quiz: Pointers

To View Tricks: Login Required

Number of Questions: 10

Question: 1 -

Choose the right option string* x, y;

Options:
  1. none of the above

  2. Both x and y are pointers to string types

  3. y is a pointer to a string, x is a string

  4. x is a pointer to a string, y is a string

  5. Answer:

    x is a pointer to a string, y is a string

    Solution:

    * is to be grouped with the variables, not the data types


Question: 2 -

Which of the following is the correct way to declare a pointer ?

Options:
  1. int &ptr

  2. All of the above

  3. int ptr

  4. int *ptr

  5. Answer:

    int *ptr

    Solution:

    int *ptr is the correct way to declare a pointer.


Question: 3 -

Which of the following gives the [value] stored at the address pointed to by the pointer : ptr?

Options:
  1. &ptr

  2. ptr

  3. Value(ptr)

  4. *ptr

  5. Answer:

    *ptr

    Solution:

    *ptr gives the [value] stored at the address pointed to by the pointer : ptr.


Question: 4 -

Generic pointers can be declared with__________ .

Options:
  1. auto

  2. void

  3. None of the above

  4. asm

  5. Answer:

    void

    Solution:

    Generic pointers can be declared with void.


Question: 5 -

A pointer can be initialized with

Options:
  1. Address of an object of same type

  2. All of the above

  3. Null

  4. Zero

  5. Answer:

    All of the above

    Solution:

    A pointer can be initialized with null, zero and Address of an object of same type.