ExamVeda
Login
Home
21
What is the diamond problem in C++ inheritance?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
22
In C++, which access specifier allows the members of a base class to be accessible in the derived class and its derived classes, but not from outside the class hierarchy?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
23
What is the default access specifier for a base class when inheriting in C++?
Discuss
Answer & Solution
Answer: Option A
Solution:
The correct answer is A: private.
Let's break down why:

In C++, when you inherit a class without explicitly specifying an access specifier (like `public`, `private`, or `protected`), the default access specifier depends on how you inherit.

If you use the `class` keyword to derive a class, the default access specifier is private.
For example, if you write `class Derived : Base`, it's the same as writing `class Derived : private Base`.

If you use the `struct` keyword to derive a class, the default access specifier is public.

This means that if you don't write `public`, `protected`, or `private` before the base class name in the inheritance, the members of the base class become `private` in the derived class (when inheriting with `class`).

Therefore, the default access specifier is private.
24
In C++, what happens if a derived class inherits multiple base classes and each base class contains a member with the same name?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
25
Which keyword is used to prevent a class from being inherited in C++?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
26
In C++, what is the process of creating a new class using an existing class as a blueprint and adding new functionalities to it?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
27
What is the term used to describe a class that inherits from another class in C++?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
28
In C++, what happens if a derived class redefines a method that is already defined in its base class?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
29
In C++, which type of inheritance involves a class inheriting from multiple classes directly or indirectly?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
30
What is the name given to the process of creating a new class by inheriting properties and behaviors from an existing class in C++?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board