[Solved] Inheritence – Mock Exam


Which of the assignment statements in someMethod are valid?

All of them.

x, this.x and super.x all point to protected int x in class A which is visible to the subclass B. this.getX() and super.getX() both call public int getX() in class A which is visible to the subclass B.

answer, x and the return value of getX() are all of type int, so the assignment is valid.

1

solved Inheritence – Mock Exam