QuestionQ13

Java Object-Oriented Approach

Given the following code:

Question Image

What is the output?

  • A mA
  • B mBmA
  • C mB
  • D mBmC
Explanation

The object referenced by cobj is an instance of C, which is also an instance of B. Therefore v.mB() executes, followed by v1.mC() after the nested instanceof C test succeeds. The output is mBmC.

Community Discussion

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