Sun Certified Java Developer Question:
Download Questions PDF

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.

Answer:

B:Compilation fails.

Download Sun Certification Interview Questions And Answers PDF

Previous QuestionNext Question
Suppose A team of programmers is reviewing a proposed API for a new utility class. After some discussion, they realize that they can reduce the number of methods in the API without losing any functionality. If they implement the new design, which two OO principles will they be promoting? A. Looser coupling B. Tighter coupling C. Lower cohesion D. Higher cohesion E. Weaker encapsulation F. Stronger encapsulationExplain 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 */ }