posted 20 years ago
This one is from the javacertificate mock exam.
Which of the following statements about default constructors are true? [Check all correct answers]
1. A default constructor is automatically provided by the compiler if no other class constructors are declared.
2. A default constructor does not have any parameters.
3. A default constructor is given a private access modifier when the class is declared with a private access modifier.
4. A default constructor declares a throw clause.
5. A default constructor invokes the superclass constructor with no arguments.
Feedback:
Answer 1,2,3 and 5 are correct.
Answer 3 is ambiguous because we cannot assume whether this question is about top-level classes or includes inner classes as well. Since a top-level class cannot be declared private or protected the statement seems true. what should one answer if such a question is posed in the Actual exam.