Quiz 8 Flashcards

(10 cards)

1
Q

In C++, protected members are inaccessible to client and to derived classes.
A) True
B) False

A

✅ B) False
Explanation: Protected members are accessible to derived (child) classes but not to outside code. Only private members are inaccessible to both.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

__________ function in C++ is a function for which the compiler attempts to replace the function call with the function’s code itself.
A) virtual
B) inline
C) final
D) friend

A

✅ B) inline
Explanation: Inline functions replace the function call with its code to reduce overhead.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In C++, instead of storing the actual method implementation inside each object, the object has a pointer to a table (vtable) that stores the addresses of dynamically bound methods.
A) True
B) False

A

✅ A) True
Explanation: Each object of a class with virtual functions has a pointer to a vtable containing addresses of overridden methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

C++ excludes classes from type checking.
A) True
B) False

A

✅ B) False
Explanation: C++ enforces compile-time type checking, including for class types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

While garbage collector reduces manual memory management, it can cause unpredictable pauses in program execution and negatively impact performance, especially in real-time or performance-critical applications.
A) True
B) False

A

✅ A) True
Explanation: Garbage collection introduces execution pauses. C++ avoids this by using manual memory management.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

All virtual functions in C++ are dynamically bound.
A) True
B) False

A

✅ A) False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

C++ offers multiple inheritance using a comma-separated list of base classes.
A) True
B) False

A

✅ A) True
Explanation: C++ supports multiple inheritance; classes can inherit from multiple parents using commas.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Some OOP languages, like Java and C++, allow you to mark methods or classes as __________, which means they cannot be overridden.
A) virtual
B) inline
C) final
D) friend

A

✅ C) final
Explanation: The final keyword prevents overriding or inheritance of methods/classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In C++, a function declared with a 0 and the keyword virtual is an abstract function and it cannot be called. It must be overridden in a derived class.
A) True
B) False

A

✅ A) True
Explanation: A pure virtual function (virtual void f() = 0;) acts like an abstract method and must be implemented by derived classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

In C++, the __________ keyword is a mechanism that allows a class to grant another class or function access to its private and protected members, which are normally hidden from other parts of the program.
A) virtual
B) inline
C) friend
D) final

A

✅ C) friend
Explanation: Friend allows specified functions or classes to access private/protected members of another class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly