Java Constructor !?
What is the expected output?
public class Profile {
private Profile(int w) { // line 1
System.out.println(w);
}
public static Profile() { // line 5
System.out.println(10);
}
public static void main(String args[]) {
Profile obj = new Profile(50);
}
}
Please choose only one answer:
50
public class Profile {
private Profile(int w) { // line 1
System.out.println(w);
}
public static Profile() { // line 5
System.out.println(10);
}
public static void main(String args[]) {
Profile obj = new Profile(50);
}
}
Please choose only one answer:
- Won't compile because of line (1) – constructor can't be private
- 10
50
- 50
- Won't compile because of line (5) – constructor can't be static
Comments
Post a Comment