Which of the following are true? (Choose 2)
this()
can be called from anywhere in a constructor. this()
can be called from any instance method in the class. this.fieldName
can be called from any instance method in the class. this.fieldName
can be called from any static method in the class. this()
. main()
method. C, G.
Since the main()
method is in the same class, it can call private methods in the class.
this()
may only be called as the first line of a constructor.
this.fieldName
can be called from any instance method to refer to an instance variable.
It cannot be called from a static method because there is no instance of the class to refer to.
Option F is tricky.
The default constructor is only written by the compiler if no user-defined constructors were provided.
this()
can only be called from a constructor in the same class.
Since there can be no user-defined constructors in the class if a default constructor was created, it is impossible for option F to be true.