Exam 1z0-809 All QuestionsBrowse all questions from this exam
Question 10

Given the content of Operator.java, EngineOperator.java, and Engine.java files:

and the code fragment:

What is the result?

    Correct Answer: A

Discussion
jduarteOption: C

answer is C becouse method is protected abstract void turnOn(); protected abstract void turnOFF();

varconiteOption: C

answer is C

Tarik2190Option: C

Answer is C: There are 2 ways to print output as ON/OFF: 1) methods turnON() and turnOFF() need to be declared as abstract. or 2) methods turnON() and turnOFF() need to be declared as protected void turnON() {some code here...}. Only then, EngineOperator class will be able to override these methods.

JME_CHGOption: C

C but if corrected, then there are 2 possibilities: 1. if all classes in same package, then D. 2. if not in same package, then A.

Tarik2190Option: C

If we do not make changes to turnON() and turnOFF() methods, then Operator class will not compile. class abstract class Operator { protected void turnON(); protected void turnOFF(); } class EngineOperator extends Operator { public final void turnON() { System.out.println("ON"); } public final void turnOFF() { System.out.println("OFF"); } } class Engine { Operator m = new EngineOperator(); public void operate() { m.turnON(); m.turnOFF(); } } public class Test { public static void main(String[] args) { Engine carEngine = new Engine(); carEngine.operate(); } }

shivkumarxOption: C

Abstract classes do not implicitly add abstract modifier Even if abstract modifier was added, the Engine class compiles fine and the code prints ON OFF

asdfjhfgjuaDCVOption: D

Answer is D.

asdfjhfgjuaDCV

C is corrcet sorry for above

steefaandOption: C

C is correct since methods are not declared abstract but dont have body.

r1muka5Option: C

Correct answer - C

dexdinh91Option: C

methods do not have body in class Operator

kartaOption: C

answer is C the Operator class turnON()& turnOFF() method need the body or change to abstract