QuestionQ122

Using Operators and Decision Constructs

Given:

Question Image

What is the resulting output?

  • A Compilation fails.
  • B false true
  • C true false
  • D true true
  • E false false
Explanation

isAvailable starts as false. The first print outputs false. doStuff() returns the negation of that value, true, which is assigned back to isAvailable; the final println outputs true. Calling a static method through an instance is permitted by Java, although class-name access is preferred.

Community Discussion

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