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

Given:

public class Canvas implements Drawable {

public void draw () { }

}

public abstract class Board extends Canvas { }

public class Paper extends Canvas {

protected void draw (int color) { }

}

public class Frame extends Canvas implements Drawable {

public void resize () { }

}

public interface Drawable {

public abstract void draw ();

}

Which statement is true?

Board does not compile.

A.

Paper does not compile.

B.

Frame does not compile.

C.

Drawable does not compile.

D.

E. All classes compile successfully.

    Correct Answer:

    All classes compile successfully. Here’s why: The Canvas class implements the Drawable interface by providing an implementation for the draw() method. The Board class, being abstract, does not need to provide an implementation for draw(). The Paper class extends Canvas and adds an overloaded method draw(int color), which is allowed and does not affect the compilation. The Frame class provides a resize() method and inherits draw() from Canvas. The Drawable interface is correctly defined. Therefore, E is the correct answer.

Discussion
M_Jawad

All classes compile successfully , Tested

adnano1234

Answer is E

steefaand

E is correct.