OOPortal OOPortal


Pointers/Memory Allocation   «Prev 

Pointers and Memory allocation in C++ - Quiz

 
1. A reference declaration creates:
  A. a new variable
  B. an alias to an existing variable
  C. a pointer
  D. an address

2. A generic pointer is declared as:
  A. char*
  B. void*
  C. word*
  D. none of these

3. The void * p pointer
  A. can be dereferenced
  B. can be added to
  C. can be compared to 0
  D. is virtual

4. After the declaration const int N = 5 is made, which of the following is illegal?
  A. cout << N
  B. if (N == i + 3)
  C. cin >> N
  D. none of these


5. The expression p = new int[20]:
  A. allocates 20 integers and assigns the base address to p
  B. allocates 20 integers off the stack local to a block
  C. reads in 20 integer values from cin
  D. allocates an integer of size 20 bytes

6. After the statement
p = new char[n];
the expression
assert(p);
tests:
  A. that p is not zero and allocation is successful
  B. that p is 1
  C. that p is an char-valued pointer
  D. none of these

7. Which form of the operator delete would you use to deallocate free store memory allocated by this statement:
student_list = new students[size]
  A. delete []student_list
  B. delete student_list
  C. delete []students
  D. delete students[size]

8. Which one of the following statements about using const is false?
  A. A const variable cannot be used on the left side of an assignment.
  B. When used alone in a declaration, the base type of a const variable is implicitly int.
  C. You cannot declare a constant pointer whose pointed-at value is constant.
  D. A const value must be initialized when it is declared.

Score =
Correct answers: