KillTest 质量更高 服务更好 学习资料 http://www.killtest.cn 半年免费更新服务
Exam : 310-055Big5 Title : Sun Certified Programmer for the Java 2 Platform.SE 5.0 Version : Demo 1 / 22
1. 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. A. 0.0 B. C. parse ParseException D. parse NumberFormatException Answer: B 2. 1. public class A { 2. public String doit(int x, int y) { 3. return "a"; 4. 5. 6. public String doit(int... vals) { 7. return "b"; 8. 9. 2 / 22
25. A a = new A(); 26. System.out.println(a.doit(4, 5)); A. 26 "a" System.out B. 26 "b" System.out C. 26 D. 6 A Answer: A 3. 10. int x = 0; 11. int y = 10; 12. do { 13. y--; 14. ++x; 15. while (x < 5); 16. System.out.print(x + "," + y); A. 5,6 B. 5,5 C. 6,5 D. 6,6 Answer: B 4. 1. public class A { 2. public void method1() { 3. try { 4. B b = new B(); 3 / 22
5. b.method2(); 6. // more code here 7. catch (TestException te) { 8. throw new RuntimeException(te); 9. 6. 7. 1. public class B { 2. public void method2() throws TestException { 3. // more code here 4. 5. 1. public class TestException extends Exception { 2. 31. public void method() { 32. A a = new A(); 33. a.method1(); 34. B 3 TestException A. 33 try B. catch A method1 C. 31 RuntimeException D. A 5 B method2 try/catch Answer: B 5. 12. public class Wow { 13. public static void go(short n) {System.out.println("short"); 14. public static void go(short n) {System.out.println("SHORT"); 4 / 22
15. public static void go(long n) {System.out.println(" LONG"); 16. public static void main(string [] args) { 17. Short y = 6; 18. int z = 7; 19. go(y); 20. go(z); 21. 22. A. short LONG B. SHORT LONG C. D. Answer: C 6. 11. String test = "This is a test"; 12. String[] tokens = test.split("\s"); 13. System.out.println(tokens.length); A. 0 B. 1 C. 4 D. E. Answer: D 7. public class NamedCounter { private final String name; 5 / 22
private int count; public NamedCounter(String name) { this.name = name; public String getname() { return name; public void increment() { count++; public int getcount() { return count; public void reset() { count = 0; A. synchronized reset() B. synchronized getname() C. synchronized getcount() D. synchronized E. synchronized increment() Answer: ACE 8. 11. class ClassA { 12. class ClassB extends ClassA { 13. class ClassC extends ClassA { 21. ClassA p0 = new ClassA(); 22. ClassB p1 = new ClassB(); 23. ClassC p2 = new ClassC(); 24. ClassA p3 = new ClassB(); 25. ClassA p4 = new ClassC(); A. p0 = p1; B. p1 = p2; C. p2 = p4; D. p2 = (ClassC)p1; 6 / 22
E. p1 = (ClassB)p3; F. p2 = (ClassC)p4; Answer: AEF 9. 10: public class Hello { 11: String title; 12: int value; 13: public Hello() { 14: title += " World"; 15: 16: public Hello(int value) { 17: this.value = value; 18: title = "Hello"; 19: Hello(); 20: 21: 30: Hello c = new Hello(5); 31: System.out.println(c.title); A. Hello B. Hello World C. D. Hello World 5 E. F. Answer: C 10. 7 / 22
1. interface DoStuff2 { 2. float getrange(int low, int high); 3. 4. interface DoMore { 5. float getavg(int a, int b, int c); 6. 7. abstract class DoAbstract implements DoStuff2, DoMore { 8. 9. class DoStuff implements DoStuff2 { 10. public float getrange(int x, int y) { return 3.14f; 11. 12. interface DoAll extends DoMore { 13. float getavg(int a, int b, int c, int d); A. B. 7 C. 12 D. 13 E. 7 12 F. 7 13 G. 7 12 13 Answer: A 11. 10. package com.sun.scjp; 11. public class Geodetics { 12. public static final double DIAMETER = 12756.32; // kilometers 13. Geodetics DIAMETER A. import com.sun.scjp.geodetics; 8 / 22
public class TerraCarta { public double halfway() { return Geodetics.DIAMETER/2.0; B. import static com.sun.scjp.geodetics; public class TerraCarta{ public double halfway() { return DIAMETER/2.0; C. import static com.sun.scjp.geodetics.*; public class TerraCarta { public double halfway() { return DIAMETER/2.0; D. package com.sun.scjp; public class TerraCarta { public double halfway() { return DIAMETER/2.0; Answer: AC 12. 10. class Nav{ 11. public enum Direction { NORTH, SOUTH, EAST, WEST 12. 13. public class Sprite{ 14. // insert code here 15. 14 Sprite A. Direction d = NORTH; B. Nav.Direction d = NORTH; C. Direction d = Direction.NORTH; D. Nav.Direction d = Nav.Direction.NORTH; Answer: D 13. 10. interface Foo { int bar(); 9 / 22
11. public class Sprite { 12. public int fubar( Foo foo ) { return foo.bar(); 13. public void testfoo() { 14. fubar( 15. // insert code here 16. ); 17. 18. 15 Sprite A. Foo { public int bar() { return 1; B. new Foo { public int bar() { return 1; C. new Foo() { public int bar() { return 1; D. new class Foo { public int bar() { return 1; Answer: C 14. 10. interface Foo { 11. int bar(); 12. 13. 14. public class Beta { 15. 16. class A implements Foo { 17. public int bar() { return 1; 18. 19. 20. public int fubar( Foo foo ) { return foo.bar(); 21. 22. public void testfoo() { 23. 10 / 22
24. class A implements Foo { 25. public int bar() { return 2; 26. 27. 28. System.out.println( fubar( new A() ) ); 29. 30. 31. public static void main( String[] argv ) { 32. new Beta().testFoo(); 33. 34. A. B. 2 C. 16 17 18 D. 24 25 26 E. 16 17 18 2 F. 24 25 26 1 Answer: BEF 15. 1. public interface A { 2. String DEFAULT_GREETING = "Hello World"; 3. public void method1(); 4. B A A. public interface B extends A { B. public interface B implements A { C. public interface B instanceof A { 11 / 22
D. public interface B inheritsfrom A { Answer: A 16. 1. class TestA { 2. public void start() { System.out.println("TestA"); 3. 4. public class TestB extends TestA { 5. public void start() { System.out.println("TestB"); 6. public static void main(string[] args) { 7. ((TestA)new TestB()).start(); 8. 9. A. TestA B. TestB C. D. Answer: B 17. 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. 12 / 22
A. test B. null C. D. 1 E. 4 F. 5 Answer: A 18. 11. public abstract class Shape { 12. int x; 13. 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. Shape Circle 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(); 13 / 22
s->setanchor(10,10); s->draw(); E. Circle c = new Circle(); c.shape.setanchor(10,10); c.shape.draw(); Answer: C 19. 10. abstract public class Employee { 11. protected abstract double getsalesamount(); 12. public double getcommision() { 13. return getsalesamount() * 0.15; 14. 15. 16. class Sales extends Employee { 17. // insert method here 18. 17 Sales A. double getsalesamount() { return 1230.45; B. public double getsalesamount() { return 1230.45; C. private double getsalesamount() { return 1230.45; D. protected double getsalesamount() { return 1230.45; Answer: BD 20. 10. interface Data { public void load(); 11. abstract class Info { public abstract void load(); Data Info A. public class Employee extends Info implements Data { public void load() { /*do something*/ 14 / 22
B. public class Employee implements Info extends Data { public void load() { /*do something*/ C. public class Employee extends Info implements Data public void load(){ /*do something*/ public void Info.load(){ /*do something*/ D. public class Employee implements Info extends Data { public void Data.load(){ /*do something*/ public void load(){ /*do something*/ E. public class Employee implements Info extends Data { public void load(){ /*do something*/ public void Info.load(){ /*do something*/ F. public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ public void Info.load() { /*do something*/ Answer: A 21. 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; 15 / 22
18. 19. Shape 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: BE 22. java.lang.runnable java.lang.cloneable A. public class Session implements Runnable, Cloneable { 16 / 22
public void run(); public Object clone(); B. public class Session extends Runnable, Cloneable { public void run() { /* do something */ public Object clone() { /* make a copy */ C. public class Session implements Runnable, Cloneable { public void run() { /* do something */ public Object clone() { /* make a copy */ D. public abstract class Session implements Runnable, Cloneable { public void run() { /* do something */ public Object clone() { /*make a copy */ E. public class Session implements Runnable, implements Cloneable { public void run() { /* do something */ public Object clone() { /* make a copy */ Answer: CD 23. 11. public interface Status { 12. /* insert code here */ int MY_VALUE = 10; 13. 12 17 / 22
A. final B. static C. native D. public E. private F. abstract G. protected Answer: ABD 24. 1. public class GoTest { 2. public static void main(string[] args) { 3. Sente a = new Sente(); a.go(); 4. Goban b = new Goban(); b.go(); 5. Stone c = new Stone(); c.go(); 6. 7. 8. 9. class Sente implements Go { 10. public void go() { System.out.println("go in Sente."); 11. 12. 13. class Goban extends Sente { 14. public void go() { System.out.println("go in Goban"); 15. 16. 17. class Stone extends Goban implements Go { 18. 19. interface Go { public void go(); 18 / 22
A. go in Goban go in Sente go in Sente B. go in Sente go in Sente go in Goban C. go in Sente go in Goban go in Goban D. go in Goban go in Goban go in Sente E. 17 Answer: C 25. 1. public class Test { 2. int x = 12; 3. public void method(int x) { 4. x+=x; 5. System.out.println(x); 6. 7. 34. Test t = new Test(); 35. t.method(5); Test 5 A. 5 B. 10 C. 12 19 / 22
D. 17 E. 24 Answer: B 26. 55. int [] x = {1, 2, 3, 4, 5; 56. int y[] = x; 57. System.out.println(y[2]); A. 57 2 B. 57 3 C. 55 D. 56 Answer: B 27. 35. String #name = "Jane Doe"; 36. int $age = 24; 37. Double _height = 123.5; 38. double ~temp = 37.5; A. 35 B. 36 C. 37 D. 38 Answer: AD 28. int A. static final int[] a = { 100,200 ; B. static final int[] a; 20 / 22
static { a=new int[2]; a[0]=100; a[1]=200; C. static final int[] a = new int[2]{ 100,200 ; D. static final int[] a; static void init() { a = new int[3]; a[0]=100; a[1]=200; Answer: AB 29. 11. public class Ball{ 12. public enum Color { RED, GREEN, BLUE ; 13. public void foo(){ 14. // insert code here 15. { System.out.println(c); 16. 17. 14 foo RED GREEN BLUE A. for( Color c : Color.values() ) B. for( Color c = RED; c <= BLUE; c++ ) C. for( Color c ; c.hasnext() ; c.next() ) D. for( Color c = Color[0]; c <= Color[2]; c++ ) E. for( Color c = Color.RED; c <= Color.BLUE; c++ ) Answer: A 30. 11. public enum Title { 12. MR("Mr."), MRS("Mrs."), MS("Ms."); 13. private final String title; 14. private Title(String t) { title = t; 15. public String format(string last, String first) { 16. return title + " " + first + " " + last; 17. 21 / 22
18. 19. public static void main(string[] args) { 20. System.out.println(Title.MR.format("Doe", "John")); 21. A. Mr. John Doe B. C. 12 D. 15 E. 20 Answer: A 22 / 22