- Home
- MCQs by exam
- NTS
NTS MCQs · Page 160
5,604 multiple choice questions typical of the NTS exam, with answers and explanations. Switch on practice mode to test yourself first.
-
A
Declares at least one pure virtual function
Correct answer
-
B
Keeps all data members private
-
C
Provides no user-defined constructor
-
D
Inherits privately from another class
-
A
Bidirectional iterators
-
B
Input iterators alone
-
C
Random-access iterators
Correct answer
-
D
Forward iterators only
-
A
Duplicate base subobjects in diamond inheritance
Correct answer
-
B
Virtual calls made on const objects
-
C
Leaks caused by missing virtual destructors
-
D
Ambiguity between overloaded operators
-
A
It can safely hold a null value
-
B
It occupies no storage whatsoever
-
C
It must be initialised when declared
Correct answer
-
D
It may be rebound to another object
-
A
It reads a whole line including spaces
-
B
It refuses input containing spaces
-
C
It skips leading whitespace before reading
Correct answer
-
D
It keeps leading whitespace as data
-
A
The function is inlined at every call site
-
B
The compiler verifies it overrides a base method
Correct answer
-
C
The base version is removed from the vtable
-
D
Subclasses may no longer override it
-
A
When a static member is assigned
-
B
When an object initialises another of its type
Correct answer
-
C
When a class declares a new object
-
D
When a virtual call is made on an object
-
A
It may read any non-static member
-
B
It must be called through an object
-
C
It is copied once per object
-
D
It has no this pointer at all
Correct answer
-
A
It gives back a void pointer
-
B
It never reports failure
-
C
It allocates memory on the stack
-
D
It runs the object's constructor
Correct answer
-
A
It must be evaluated at compile time
-
B
It promises not to modify the object
Correct answer
-
C
It returns a constant value
-
D
It can be called only one time
-
A
std::list
-
B
std::unordered_map
Correct answer
-
C
std::map
-
D
std::vector
-
A
A has-a relationship between the classes
-
B
A uses-a relationship between the classes
-
C
A part-of relationship between the classes
-
D
An is-a relationship between the classes
Correct answer
-
A
The derived part is sliced away
Correct answer
-
B
The base part is discarded
-
C
The copy keeps both dynamic parts
-
D
The compiler rejects the copy
-
A
So derived classes skip the base destructor
-
B
So the object is reclaimed by a collector
-
C
So deleting through a base pointer is complete
Correct answer
-
D
So the destructor may be called twice
-
A
Reverse of their construction order
Correct answer
-
B
Same as their construction order
-
C
In alphabetical order of names
-
D
In an order chosen by the linker
-
A
Amortised constant time
Correct answer
-
B
Logarithmic in the size
-
C
Linear in the size every time
-
D
Quadratic in the size
-
A
When the object is first read from
-
B
When the enclosing scope ends
-
C
Only when new is used to create it
-
D
When the object comes into existence
Correct answer
-
A
To stop derived classes from redefining it
-
B
To force the function to be inlined everywhere
-
C
To hide the function from other translation units
-
D
To allow dispatch at runtime through a base pointer
Correct answer
-
A
a + i
-
B
*(a + i)
Correct answer
-
C
*(a + i * 4)
-
D
&a[i]
-
A
It allocates memory for the type
-
B
It makes every member static
-
C
It blocks copying of the struct
-
D
It creates an alias for the type
Correct answer
-
A
1
-
B
2
-
C
3
-
D
0
Correct answer
-
A
To allow it to read wide characters
-
B
To make it faster than putchar
-
C
So that EOF can be told apart from data
Correct answer
-
D
Because characters are stored as int
-
A
The block is simply released again
-
B
A compile-time error in every compiler
-
C
The pointer is set to NULL for you
-
D
Undefined behaviour and possible heap damage
Correct answer
-
A
Only the source characters, no null
-
B
At most n characters from the source
-
C
The address of the source string
-
D
The source characters and its null byte
Correct answer
-
A
They must be listed in ascending order
-
B
They must be integer constant expressions
Correct answer
-
C
They must be distinct string literals
-
D
They must be variables of type int