Sun Certified Java Developer Question:
Download Questions PDF

Explain Given:
11. public abstract class Shape {
12. private int x;
13. private int y;
14. public abstract void draw();
15. public void setAnchor(int x, int y) {
16. this.x = x;
17. this.y = y;
18. }
19. }
Which two classes use the Shape class correctly? (Choose two.)
A. public class Circle implements Shape {
private int radius;
}
B. public abstract class Circle extends Shape {
private int radius;
}
C. public class Circle extends Shape {
private int radius;
public void draw();
}
D. public abstract class Circle implements Shape { private int radius;
public void draw();
}
E. public class Circle extends Shape {
private int radius;
public void draw() {/* code here */}
F. public abstract class Circle implements Shape { private int radius;
public void draw() { /* code here */ }

Answer:

B:public abstract class Circle extends Shape {
private int radius;
}
E:public class Circle extends Shape {
private int radius;
public void draw() {/* code here */}

Download Sun Certification Interview Questions And Answers PDF

Previous QuestionNext Question
Explain Given: 11. public static void parse(String str) { 12. try { 13. float f = Float.parseFloat(str); 14. } catch (NumberFormatException nfe) { 15. f = 0; 16. } finally { 17. System.out.println(f); 18. } 19. } 20. public static void main(String[] args) { 21. parse("invalid"); 22. } What is the result? A. 0.0 B. Compilation fails. C. A ParseException is thrown by the parse method at runtime. D. A NumberFormatException is thrown by the parse method at runtime.Explain Given: 5. class Atom { 6. Atom() { System.out.print("atom "); } 7. } 8. class Rock extends Atom { 9. Rock(String type) { System.out.print(type); } 10. } 11. public class Mountain extends Rock { 12. Mountain() { 13. super("granite "); 14. new Rock("granite "); 15. } 16. public static void main(String[] a) { new Mountain(); } 17. } What is the result? A. Compilation fails. B. atom granite C. granite granite D. atom granite granite E. An exception is thrown at runtime. F. atom granite atom granite