ProgrammingEasyAccenture · Cognizant pattern
What is the return type of a C++ constructor?
- A. int
- B. The class type
- C. It has no return type, not even void
- D. void
Correct answer: C. It has no return type, not even void
A constructor is declared with the class name and no return type at all; writing void before it makes it an ordinary (badly named) function instead.
More OOP with C++ and Java questions
- Every Java class that declares no superclass implicitly extends:
- In C++, members of a class declared without any access specifier are:
- Which statement about Java String objects is correct?
- What is printed? java String s = "ab"; s.concat("cd"); s.toUpperCase(); System.out.print(s);
- Which pairing is correct?
- Which of these operators cannot be overloaded in C++?