Under what situations does a class get a default constructor?
- All classes in Java get a default constructor.
- You have to define at least one constructor to get the default constructor.
- If the class does not define any constructors explicitly.
- All classes get default constructor from Object class.
- None of the above.
I selected None of the above, because if a class extends another class without a no-args constructor, it does not get the default constructor.
Code: Select all
public class App {
public App(int i) {
}
class SubApp extends App (){
}
}
Have I misunderstood the question?