ExamVeda
Login
Home
31
Which of the following statements about constructor initialization lists in C++ is correct?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
32
Which of the following statements is true about constructors in C++?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
33
What is the purpose of using default arguments in C++ constructors?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
34
Which statement about constructor inheritance in C++ is correct?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
35
Which statement about destructors in C++ is true?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
36
Which operator is used to access members of an object in C++?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
37
What is the access specifier that allows constructors to be called only from member functions of the same class and its derived classes in C++?
Discuss
Answer & Solution
Answer: Option C
Solution:
In C++, the access specifier that allows constructors to be called only from member functions of the same class and its derived classes is private. When a constructor is declared as private, it cannot be accessed from outside the class, limiting its invocation to member functions of the same class and its derived classes.

Option A: protected allows access to member functions and data members from within the same class, derived classes, and friend classes, but it still allows derived classes to call constructors, which might not be desired in some cases.
Option B: public allows unrestricted access to the constructor from anywhere, defeating the purpose of restricting its usage to only member functions of the same class and its derived classes.
Option D: friend allows non-member functions or external classes to access private and protected members of a class, but it doesn't restrict the calling of constructors to member functions of the same class and its derived classes.

Therefore, the correct answer is Option C: private.
38
What happens if the destructor is explicitly defined in a C++ class, but the constructor is not defined?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
39
What is the purpose of using the delete keyword in C++ destructors?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
40
Which of the following is correct?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board