ExamVeda
Login
Home
Constructors and Methods
?

What is the expected output?
public class Profile {
         private Profile(int w) { // line 1
                  System.out.print(w);
         }
         public static Profile() { // line 5
                  System.out.print (10);
         }
         public static void main(String args[]) {
                  Profile obj = new Profile(50);
         }
}

Answer & Solution
Correct Answer: Option D

Only public, protected, private and default (no access modifier) are legal while declaring constructors.

Examveda
Question posted by Examveda
Community

Join the Discussion

2 Comments
Sachin Chitme
Sachin Chitme 9 years ago
Not able to understand
SURBHI MITTAL
SURBHI MITTAL 10 years ago
constructors can never be declared static