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 final Profile() { // line 5
		System.out.print(10);
	}
	public static void main(String args[]) {
		Profile obj = new Profile(50);
	}
}

Answer & Solution
Correct Answer: Option B

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

Examveda
Question posted by Examveda
Community

Join the Discussion

1 Comment
Vamsi Meka
Vamsi Meka 4 years ago
why