What is the result?

Given:


What is the result?
A. Initialized
Started
B. Initialized
Started
Initialized
C. Compilation fails
D. An exception is thrown at runtime

Download Printable PDF. VALID exam to help you PASS.

One thought on “What is the result?

  1. C is the correct answer.
    The program will not compile because method init() is private and not visible outside of class Caller. If access to init() was changed to public, choice B would be correct.

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

    public class TestCaller{
    public static void main(String[] args){
    Caller c = new Caller();
    c.start();
    c.init();
    }
    }

Leave a Reply

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


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