Oracle
1Z0-851 · Question #251
Given: public abstract class Shape { private int x; private int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y; } } Which two classes use the Shape…
The correct answer is B. public abstract class Circle extends Shape { private int radius; } E. public class Circle extends Shape { private int radius; public void draw() {/* code here */}. See the full explanation below for the reasoning.
Question
Given: public abstract class Shape { private int x; private int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y; } } Which two classes use the Shape class correctly? (Choose two.)
Options
- Apublic class Circle implements Shape { private int radius; }
- Bpublic abstract class Circle extends Shape { private int radius; }
- Cpublic class Circle extends Shape { private int radius; public void draw(); }
- Dpublic abstract class Circle implements Shape { private int radius; public void draw(); }
- Epublic class Circle extends Shape { private int radius; public void draw() {/* code here */}
- Fpublic abstract class Circle implements Shape { private int radius; public void draw() { /* code here */ }
How the community answered
(28 responses)- B75% (21)
- C14% (4)
- D4% (1)
- F7% (2)
Community Discussion
No community discussion yet for this question.