JavaScript is required

What is output of following code?
Media VietJack

A.
400 2
B.
400 400
C.
400 401
D.
Complier error
Trả lời:

Đáp án đúng: A


The code uses inheritance with a `Parent` class and a `Child` class inheriting from it. A `Child` object is created and `p.show()` is called. Due to polymorphism, `Child`'s `show()` method is executed. Inside `Child`'s `show()`, `super.show()` calls `Parent`'s `show()`, printing `x` (400). Then, `Child`'s `show()` prints its own `x` (401). Thus, the output is `400 401`.

Câu hỏi liên quan