Home / Java Programming / Declarations and Access Control :: Discussion

Discussion :: Declarations and Access Control

  1. public class Test { } 
    What is the prototype of the default constructor?

  2. A.
    Test( )
    B.
    Test(void)
    C.
    public Test( )
    D.
    public Test(void)

    View Answer

    Workspace

    Answer : Option C

    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.


Be The First To Comment