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?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.
Saritha said:
1 decade ago
If the class having the access modifier as private. Then is it the default constructor of class is private?
Mahesh said:
1 decade ago
Option A is wrong. The default constructor has the same access modifier as the class. Here the is defined public so default constructor must be public. And Test() is in default access level.
The compiler will not implicitly put "public" in front of Test().
The compiler will not implicitly put "public" in front of Test().
Ashwin said:
1 decade ago
Why the option A is wrong ?
The compiler will implicitly put "public" in front of Test(). Then why this option is wrong.
And wht do you mean by prototype ?
The compiler will implicitly put "public" in front of Test(). Then why this option is wrong.
And wht do you mean by prototype ?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers