OCA Java SE 8 Method - OCA Mock Question Method 6








Question

Which of the following are true?

  1. You can call this() from anywhere in a constructor.
  2. You can call this() from any instance method in the class.
  3. You can call this.variableName from instance method in the class.
  4. You can call this.variableName from static method in the class.
  5. You can call the default constructor added by the compiler using this().
  6. You can access a private constructor inside the main() method.




Answer



C, F.

Note

this() can be called in the instance constructor as the first statement provided that a constructor without parameter is defined.

We can access the private constructor within the same class from main method.