Java Programming - Declarations and Access Control - Discussion

Discussion Forum : Declarations and Access Control - General Questions (Q.No. 5)
5.
public class Test { }
What is the prototype of the default constructor?
Test( )
Test(void)
public Test( )
public Test(void)
Answer: Option
Explanation:

Option A and B are wrong because they use the default access modifier and the access modifier for the class is public (remember, the default constructor has the same access modifier as the class).

Option D is wrong. The void makes the compiler think that this is a method specification - in fact if it were a method specification the compiler would spit it out.

Discussion:
13 comments Page 2 of 2.

Mohan said:   1 decade ago
What is the prototype of constructor in before creating an object?

PRANAY said:   8 years ago
Option A is correct.

And I agree @Jothi Pandiyan.

Shubhamsinh said:   6 years ago
I think Option A is correct.


Post your comments here:

Your comments will be displayed after verification.