Q. – Given :-
public class Caller {
private void init( ) {
System.out.println("Initialized");
}
protected void start( ) {
init();
System.out.println("Started");
}
}
public class TestCall {
public static void main(String[ ] args) {
Caller c= new Caller ( );
c.start(); // line n1
c.init(); // line n2
}
}
What is the result?
A) Compilation fails at line n1.
B) Initialized
Started
C) Initialized
Started
Initialized
D) Compilation fails at line n2.
⧪ please give your answer in a comment section.
public class Caller {
private void init( ) {
System.out.println("Initialized");
}
protected void start( ) {
init();
System.out.println("Started");
}
}
public class TestCall {
public static void main(String[ ] args) {
Caller c= new Caller ( );
c.start(); // line n1
c.init(); // line n2
}
}
What is the result?
A) Compilation fails at line n1.
B) Initialized
Started
C) Initialized
Started
Initialized
D) Compilation fails at line n2.
⧪ please give your answer in a comment section.
3 Comments
Option C
ReplyDeleteD
ReplyDeleteD
ReplyDelete