QuestionQ178

Working with Methods and Encapsulation

Given the following code:

Question Image

What is the outcome?

  • A An exception is thrown at runtime.
  • B Initialized Started Initialized
  • C Initialized Started
  • D Compilation fails.
Explanation

init() and start() are private members of Caller, so they cannot be called from the separate TestCall class. The calls c.start() and c.init() cause compilation errors.

Community Discussion

No comments yet. Be the first to start the discussion!