OCA Java SE 8 Mock Exam Review - OCA Mock Question 22








Question

Which of the following are valid constructors within a class Test.

  1. test() { }
  2. Test() { }
  3. void Test() { }
  4. private final Test() { }
  5. abstract Test() { }
  6. Test(Test t) { }
  7. Test(void) { }




Answer



B, F.

Note

A constructor must have the same name as the class, hence a is not a constructor.

It must not return any value, hence c is not correct.

A constructor cannot be declared abstract or final.