单项选择题
public abstract class Shape {
int x;
int y;
public abstract void draw();
public void setAnchor(int x, int y) {
this.x = x;
this.y = y;
}
}
and a class Circle that extends and fully implements the Shape class. Which is correct?()
A. Shape s = new Shape(); s.setAnchor(10,10); s.draw();
B. Circle c = new Shape(); c.setAnchor(10,10); c.draw();
C. Shape s = new Circle(); s.setAnchor(10,10); s.draw();
D. Shape s = new Circle(); s->setAnchor(10,10); s->draw();
E. Circle c = new Circle(); c.Shape.setAnchor(10,10); c.Shape.draw();
相关考题
-
单项选择题
1. interface TestA { String toString(); } 2. public class Test { 3. public static void main(String[] args) { 4. System.out.println(new TestA() { 5. public String toString() { return “test”; } 6. } 7. } 8. } What is the result?()
A. test
B. null
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 1.
E. Compilation fails because of an error in line 4.
F. Compilation fails because of an error in line 5. -
单项选择题
class TestA { public void start() { System.out.println(”TestA”); } } public class TestB extends TestA { public void start() { System.out.println(”TestB”); } public static void main(String[] args) { ((TestA)new TestB()).start(); } } What is the result?()
A. TestA
B. TestB
C. Compilation fails.
D. An exception is thrown at runtime. -
单项选择题
public interface A { String DEFAULT_GREETING = “Hello World”; public void method1(); } A programmer wants to create an interface called B that has A as its parent. Which interface declaration is correct?()
A. public interface B extends A {}
B. public interface B implements A {}
C. public interface B instanceOf A {}
D. public interface B inheritsFrom A {}
