Java OCA OCP Practice Question 1417

Question

Given a class named MyClass, which of these would be valid definitions for the constructors for the class?

Select 1 option

  • A. MyClass (MyClass b) { }
  • B. MyClass MyClass ( ) { }
  • C. private final MyClass ( ) { }
  • D. void MyClass ( ) { }
  • E. public static void MyClass (String args [] ) { }


Correct Option is  : A

Note

For Option A.

The constructor can take the same type as a parameter.

For Option B.

A constructor cannot return anything.

For Option C.

A constructor cannot be final, static or abstract.

For Option D.

A constructor cannot return anything not even void.

For Option E.

A constructor cannot be final, static or abstract.




PreviousNext

Related