What is the result?

Given:
class Caller {
private void init () {
System.out.println("Initialized");
}
private void start () {
init(];
System.out.println("Started") ;
}
public class TestCall {
public static void main(String[] args) { Caller c – new Caller(); c.start (); c.init();
}
}
What is the result?
A. An exception is thrown at runtime.
B. Initialized Started Initialized
C. Initialized Started
D. Compilation fails.

Download Printable PDF. VALID exam to help you PASS.

6 thoughts on “What is the result?

  1. Answer D:

    We have here two classes. The caller class is calling private methods. Therefore, compilation fails.

  2. Because the main method is static but TestCall class is not. Actually, every static method must be in a static class.

Leave a Reply

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


The reCAPTCHA verification period has expired. Please reload the page.