Leave a Reply 5

Your email address will not be published. Required fields are marked *


ana

ana

correct answer is A

sil

sil

D

sil

sil

You cannot call private methods from outside the class they were declared.

renko

renko

Answer: D
package q039;

public class Caller {
private void init() {
System.out.println(“Initialized”);
}

private void start() {
init();
System.out.println(“Started”);
}
}
package q039;

public class TestCall {

public static void main(String[] args) {
Caller c = new Caller();
c.start(); //start is private
c.init(); //init() is also private
}

}
Output:
Exception in thread “main” java.lang.Error: Unresolved compilation problems:
The method start() from the type Caller is not visible
The method init() from the type Caller is not visible
output cannot be resolved or is not a field

at q039.TestCall.main(TestCall.java:7)