Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 104

Given:

Automobile.java -

Car.java -

What must you do so that the code prints 4?

    Correct Answer: A

    To make the code print 4, you need to ensure that the method in the Car class correctly overrides the abstract method in the Automobile class. The abstract method in the Automobile class is defined without parameters (abstract void wheels();), while the method in the Car class takes an int parameter (void wheels(int i)). This means that the method in the Car class does not override the abstract method in the Automobile class, and hence when ob.wheels() is called, it leads to a missing method implementation. By removing the parameter from the wheels method in the Car class, you ensure that it correctly overrides the abstract method in the Automobile class, fulfilling the requirement and allowing the code to print 4.

Discussion
d7bb0b2Option: A

A is correct: 1- abstract method need a impletation 2- the method that call when is override is by real type of object not declared type (abstract class). So if you remove is override method so when call is print 4

OmnisumemOption: A

Tested: A.

StavokOption: A

A is correct TESTED