Question 5 / 297:  What is the expected output?
public class Profile {

private Profile(int w) { // line 1

System.out.println(w);

}

public final Profile() { // line 5

System.out.println(10);

}

public static void main(String args[]) {

Profile obj = new Profile(50);

}

}

A  Won't compile because of line (1) – constructor can't be private
B  Won't compile because of line (5) – constructor can't be final
C  50
D  10 50
<< First < Previous Next > Last >>
Explanation:

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

Exam Home Page
Ask
Eric Crawford
Start Quiz
Dionne Mahaffey
Start Quiz
Dravida Mahadeo-J...
Start Quiz
Copy and paste the following HTML code into your website or blog.
<iframe src="https://www.jobilize.com/embed/java-certification-questions" width="600" height="600" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes" style="border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px" allowfullscreen webkitallowfullscreen mozallowfullscreen> </iframe>