Vidyalelo
Java Programming · Q54

Constructors and Methods

Programming · Java Programming · question 54

Q54

public class MyClass For the above class(MyClass) what is the correct way of declaring constructor?

A.
MyClass(){}
B.
MyClass(void) {}
C.
public MyClass(){}
D.
public MyClass(void){}
E.
1 and 3
Answer

Answer: Option E

Solution

Answer: Option E
Solution:

Choice A,C are the correct answers.
The default access specifier for any constructor is same as the access specifier of class.so the options A and C are correct.