为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

310-055

2012-03-21 13页 pdf 678KB 7阅读

用户头像

is_309808

暂无简介

举报
310-055 Exam  :  SUN 310­055  Title  :  Update :  Demo  Sun Certified Programmer for the  Java 2 Platform.SE 5.0  http://www.KillTest.com |  English  |  Chinese(Traditional)  |  Chinese(Simplified)  |  ­ 2 ­  KillTest Information Co., Ltd. All rights reserved.  1....
310-055
Exam  :  SUN 310­055  Title  :  Update :  Demo  Sun Certified Programmer for the  Java 2 Platform.SE 5.0  http://www.KillTest.com |  English  |  Chinese(Traditional)  |  Chinese(Simplified)  |  ­ 2 ­  KillTest Information Co., Ltd. All rights reserved.  1.Which Man class properly represents the relationship "Man has a best friend who is a Dog"?  A.class Man extends Dog { }  B.class Man implements Dog { }  C.class Man { private BestFriend dog; }  D.class Man { private Dog bestFriend; }  E.class Man { private Dog; }  F.class Man { private BestFriend; }  Correct:D  2.Given: 1. package test; 2. 3. class Target { 4. public String name = "hello"; 5.  } What can directly access and  change the value of the variable name?  A.any class  B.only the Target class  C.any class in the test package  D.any class that extends Target  Correct:C  3.Click the Task button.  Correct:  Green choice1‐‐‐‐>Yellow Choice1  Green choice2‐‐‐‐>Yellow Choice2  Green choice3‐‐‐‐>Yellow Choice3  Green choice5‐‐‐‐>Yellow Choice5  Green choice4‐‐‐‐>Yellow Choice6  Green choice1‐‐‐‐>Yellow Choice4  4.Given:  1.  class  ClassA  {  2.  public  int  numberOfInstances;  3.  protected  ClassA(int  numberOfInstances)  {  4.  this.numberOfInstances  =  numberOfInstances;  5.  }  6.  }  7.  public  class  ExtendedA  extends  ClassA  {  8.  private  ExtendedA(int numberOfInstances) { 9. super(numberOfInstances); 10. } 11. public static void main(String[] args)  {  12.  ExtendedA  ext  =  new  ExtendedA(420);  13.  System.out.print(ext.numberOfInstances);  14.  }  15.  } Which  statement is true? |  English  |  Chinese(Traditional)  |  Chinese(Simplified)  |  ­ 3 ­  KillTest Information Co., Ltd. All rights reserved.  A.420 is the output.  B.An exception is thrown at runtime.  C.All constructors must be declared public.  D.Constructors CANNOT use the private modifier.  E.Constructors CANNOT use the protected modifier.  Correct:A  5.Given: 10. interface Jumper { public void jump(); } ... 20. class Animal {} ... 30. class Dog extends Animal { 31.  Tail tail; 32. } ... 40. class Beagle extends Dog implements Jumper{ 41. public void jump() {} 42. } ... 50. class Cat  implements Jumper{ 51. public void jump() {} 52. } Which three are true? (Choose three.)  A.Cat is‐a Animal  B.Cat is‐a Jumper  C.Dog is‐a Animal  D.Dog is‐a Jumper  E.Cat has‐a Animal  F.Beagle has‐a Tail  G.Beagle has‐a Jumper  Correct:B C F  6.Given: 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: } and: 30: Hello c = new  Hello(5); 31: System.out.println(c.title); What is the result?  A.Hello  B.Hello World  C.Compilation fails.  D.Hello World 5  E.The code runs with no output.  F.An exception is thrown at runtime.  Correct:C  7.Given: 10. interface A { public int getValue(); } 11. class B implements A { 12. public int getValue() { return 1; }  13.  } 14. class C extends B { 15. //  insert code here 16. } Which three code fragments, inserted  individually at  line 15, make use of polymorphism? (Choose three.)  A.public void add(C c) { c.getValue(); }  B.public void add(B b) { b.getValue(); }  C.public void add(A a) { a.getValue(); }  D.public void add(A a, B b) { a.getValue(); }  E.public void add(C c1, C c2) { c1.getValue(); }  Correct:B C D  8.Given:  20. public  class  CreditCard  {  21.  22. private  String  cardID;  23.  private  Integer  limit;  24.  public  String  ownerName; 25. 26. public void setCardInformation(String cardID, 27. String ownerName, 28. Integer limit) { 29.  this.cardID = cardID; 30. this.ownerName = ownerName; 31. this.limit = limit; 32. } 33. } Which statement is true?  A.The class is fully encapsulated.  B.The code demonstrates polymorphism.  C.The ownerName variable breaks encapsulation.  D.The cardID and limit variables break polymorphism. |  English  |  Chinese(Traditional)  |  Chinese(Simplified)  |  ­ 4 ­  KillTest Information Co., Ltd. All rights reserved.  E.The setCardInformation method breaks encapsulation.  Correct:C  9.Given: 1. class Super { 2. private int a; 3. protected Super(int a) { this.a = a; } 4. } ... 11. class Sub extends Super  { 12. public Sub(int a) { super(a); } 13. public Sub() { this.a = 5; } 14. } Which two, independently, will allow Sub  to compile? (Choose two.)  A.Change line 2 to: public int a;  B.Change line 2 to: protected int a;  C.Change line 13 to: public Sub() { this(5); }  D.Change line 13 to: public Sub() { super(5); }  E.Change line 13 to: public Sub() { super(a); }  Correct:C D  10.Given: 11. class ClassA {} 12. class ClassB extends ClassA {} 13. class ClassC extends ClassA {} and: 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(); Which three are valid? (Choose three.)  A.p0 = p1;  B.p1 = p2;  C.p2 = p4;  D.p2 = (ClassC)p1;  E.p1 = (ClassB)p3;  F.p2 = (ClassC)p4;  Correct:A E F  11.Given: 1. public class Threads2 implements Runnable { 2. 3. public void run() { 4. System.out.println("run.");  5.  throw new RuntimeException("Problem"); 6.  } 7. public  static void main(String[] args)  { 8.  Thread  t = new  Thread(new  Threads2());  9.  t.start();  10.  System.out.println("End of method.");  11.  }  12.  } Which  two  can  be  results? (Choose two.)  A.java.lang.RuntimeException: Problem  B.run. java.lang.RuntimeException: Problem  C.End of method. java.lang.RuntimeException: Problem  D.End of method. run. java.lang.RuntimeException: Problem  E.run. java.lang.RuntimeException: Problem End of method.  Correct:D E  12.Given:  1.  public  class  TestOne  {  2.  public  static  void  main  (String[]  args)  throws  Exception  {  3.  Thread.sleep(3000); 4. System.out.println("sleep"); 5. } 6. } What is the result?  A.Compilation fails.  B.An exception is thrown at runtime.  C.The code executes normally and prints "sleep".  D.The code executes normally, but nothing is printed.  Correct:C  13.Given: 1. public class Threads3 implements Runnable { 2. public void run() { 3. System.out.print("running");  4. } 5. public static void main(String[] args) { 6. Thread t = new Thread(new Threads3()); 7. t.run(); 8. t.run(); 9.  t.start(); 10. } 11. } What is the result?  A.Compilation fails.  B.An exception is thrown at runtime. |  English  |  Chinese(Traditional)  |  Chinese(Simplified)  |  ­ 5 ­  KillTest Information Co., Ltd. All rights reserved.  C.The code executes and prints "running".  D.The code executes and prints "runningrunning".  E.The code executes and prints "runningrunningrunning".  Correct:E  14.Click the Exhibit button. Which two are possible results? (Choose two.)  A.0, 2, 4, 4, 6, 8, 10, 6,  B.0, 2, 4, 6, 8, 10, 2, 4,  C.0, 2, 4, 6, 8, 10, 12, 14,  D.0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14,  E.0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14,  Correct:A C  15.Click the Exhibit button. What is the result? |  English  |  Chinese(Traditional)  |  Chinese(Simplified)  |  ­ 6 ­  KillTest Information Co., Ltd. All rights reserved.  A.The code will deadlock.  B.The code may run with no output.  C.An exception is thrown at runtime.  D.The code may run with output "0 6".  E.The code may run with output "2 0 6 4".  F.The code may run with output "0 2 4 6".  Correct:F  16.Click the Task button. |  English  |  Chinese(Traditional)  |  Chinese(Simplified)  |  ­ 7 ­  KillTest Information Co., Ltd. All rights reserved.  Correct:  Green choice1‐‐‐‐>Yellow Choice1  Green choice1‐‐‐‐>Yellow Choice2  Green choice2‐‐‐‐>Yellow Choice3  Green choice2‐‐‐‐>Yellow Choice4  Green choice2‐‐‐‐>Yellow Choice5  Green choice2‐‐‐‐>Yellow Choice6  17.Which two code fragments will execute the method doStuff() in a separate thread? (Choose two.)  A.new Thread() { public void run() { doStuff(); } };  B.new Thread() { public void start() { doStuff(); } };  C.new Thread() { public void start() { doStuff(); } }.run();  D.new Thread() { public void run() { doStuff(); } }.start();  E.new Thread(new Runnable() { public void run() { doStuff(); } }).run();  F.new Thread(new Runnable() { public void run() { doStuff(); } }).start();  Correct:D F  18.Given: public class NamedCounter { private final String name; 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; } } Which three changes should be made to adapt  this class to be used safely by multiple threads? (Choose three.)  A.declare reset() using the synchronized keyword  B.declare getName() using the synchronized keyword  C.declare getCount() using the synchronized keyword  D.declare the constructor using the synchronized keyword  E.declare increment() using the synchronized keyword  Correct:A C E  19.Click the Task button. |  English  |  Chinese(Traditional)  |  Chinese(Simplified)  |  ­ 8 ­  KillTest Information Co., Ltd. All rights reserved.  Correct:  Green choice1‐‐‐‐>Yellow Choice1  Green choice5‐‐‐‐>Yellow Choice2  Green choice3‐‐‐‐>Yellow Choice5  Green choice16‐‐‐‐>Yellow Choice3  Green choice10‐‐‐‐>Yellow Choice4  20.Given: 1. import java.util.*; 2. public class WrappedString { 3. private String s; 4. public WrappedString(String  s) { this.s = s; } 5. public static void main(String[] args) { 6. HashSeths = new HashSet(); 7. WrappedString ws1 =  new WrappedString("aardvark"); 8. WrappedString ws2 = new WrappedString("aardvark");  9.  String s1 = new  String("aardvark"); 10. String s2 = new String("aardvark"); 11. hs.add(ws1); hs.add(ws2); hs.add(s1); hs.add(s2);  12. System.out.println(hs.size()); } } What is the result?  A.0  B.1  C.2  D.3  E.4  F.Compilation fails.  G.An exception is thrown at runtime.  Correct:D  21.Click the Task button. |  English  |  Chinese(Traditional)  |  Chinese(Simplified)  |  ­ 9 ­  KillTest Information Co., Ltd. All rights reserved.  Correct:  Green choice15‐‐‐‐>Yellow Choice1  Green choice11‐‐‐‐>Yellow Choice6  Green choice7‐‐‐‐>Yellow Choice4  Green choice10‐‐‐‐>Yellow Choice2  Green choice14‐‐‐‐>Yellow Choice7  Green choice12‐‐‐‐>Yellow Choice8  Green choice13‐‐‐‐>Yellow Choice3  Green choice16‐‐‐‐>Yellow Choice5  22.Click the Task button. |  English  |  Chinese(Traditional)  |  Chinese(Simplified)  |  ­ 10 ­  KillTest Information Co., Ltd. All rights reserved.  Correct:  Green choice2‐‐‐‐>Yellow Choice1  Green choice1‐‐‐‐>Yellow Choice2  Green choice3‐‐‐‐>Yellow Choice3  Green choice3‐‐‐‐>Yellow Choice4  23.Given: 1. public class Drink implements Comparable { 2. public String name; 3. public int compareTo(Object o)  { 4. return 0; 5. } 6. } and: 20. Drink one = new Drink(); 21. Drink two = new Drink(); 22. one.name= "Coffee"; 23.  two.name= "Tea"; 24. TreeSet  set = new TreeSet(); 25.  set.add(one); 26.  set.add(two); A programmer  iterates  over the TreeSet and prints the name of each Drink object. What is the result?  A.Tea  B.Coffee  C.Coffee Tea  D.Compilation fails.  E.The code runs with no output.  F.An exception is thrown at runtime.  Correct:B  24.Given:  11.  //  insert  code here  12.  private N min, max;  13. public N getMin()  {  return min;  }  14.  public N  getMax()  {  return  max;  }  15.  public  void  add(N  added)  {  16.  if  (min  ==  null  ||  added.doubleValue()  <  min.doubleValue()) 17. min = added; 18. if (max == null || added.doubleValue() > max.doubleValue()) 19. max =  added; 20. } 21. } Which two, inserted at line 11, will allow the code to compile? (Choose two.)  A.public class MinMax { |  English  |  Chinese(Traditional)  |  Chinese(Simplified)  |  ­ 11 ­  KillTest Information Co., Ltd. All rights reserved.  B.public class MinMax {  C.public class MinMax {  D.public class MinMax {  E.public class MinMax {  F.public class MinMax {  Correct:D F  25.Given: enum Example { ONE, TWO, THREE } Which statement is true?  A.The expressions (ONE == ONE) and ONE.equals(ONE) are both guaranteed to be true.  B.The expression (ONE < TWO) is guaranteed to be true and ONE.compareTo(TWO) is guaranteed to be less than  one.  C.The  Example  values  cannot  be  used  in  a  raw  java.util.HashMap;  instead,  the  programmer  must  use  a  java.util.EnumMap.  D.The Example values can be used  in a  java.util.SortedSet, but the  set will NOT be  sorted because enumerated  types do NOT implement java.lang.Comparable.  Correct:A  26.Given: 1.  import  java.util.*; 2. public  class Example  { 3. public  static void main(String[] args)  { 4.  //  insert  code here 5. set.add(new Integer(2)); 6. set.add(new Integer(1)); 7. System.out.println(set); 8. } 9. } Which code,  inserted at line 4, guarantees that this program will output [1, 2]?  A.Set set = new TreeSet();  B.Set set = new HashSet();  C.Set set = new SortedSet();  D.List set = new SortedList();  E.Set set = new LinkedHashSet();  Correct:A  27.Click the Task button.  Correct:  Green choice1‐‐‐‐>Yellow Choice1 |  English  |  Chinese(Traditional)  |  Chinese(Simplified)  |  ­ 12 ­  KillTest Information Co., Ltd. All rights reserved.  Green choice3‐‐‐‐>Yellow Choice2  Green choice2‐‐‐‐>Yellow Choice3  Green choice3‐‐‐‐>Yellow Choice4  Green choice3‐‐‐‐>Yellow Choice5  28.Given: 11. public class Key { 12. private  long  id1; 13. private  long  id2; 14. 15. // class Key methods 16.  } A  programmer  is developing a class Key, that will be used as a key  in a standard  java.util.HashMap. Which two  methods should be overridden to assure that Key works correctly as a key? (Choose two.)  A.public int hashCode()  B.public boolean equals(Key k)  C.public int compareTo(Object o)  D.public boolean equals(Object o)  E.public boolean compareTo(Key k)  Correct:A D  29.Given:  11.  String  test  =  "This  is  a  test";  12.  String[]  tokens  =  test.split("\s");  13.  System.out.println(tokens.length); What is the result?  A.0  B.1  C.4  D.Compilation fails.  E.An exception is thrown at runtime.  Correct:D  30.Given: 12. public class Wow { 13. public static void go(short n) {System.out.print("short ");} 14. public static  void go(Short n) {System.out.print("SHORT ");} 15. public static void go(Long n) {System.out.print(" LONG ");} 16.  public static void main(String [] args) { 17. Short y = 6; 18. int z = 7; 19. go(y); 20. go(z); 21. } 22. } What is the  result?  A.short LONG  B.SHORT LONG  C.Compilation fails.  D.An exception is thrown at runtime.  Correct:C KillTest.com was founded in 2006. The safer,easier way to help you pass any IT  Certification exams . We provide high quality IT Certification exams practice  questions and answers(Q&A). Especially  Adobe,  Apple,  Citrix,  Comptia,  EMC,  HP,  HuaWei,  LPI,  Nortel,  Oracle,  SUN,  Vmware  and so on. And help you pass  any IT Certification exams at the first try.  You can reach us at any of the email addresses listed below.  English Customer:  Chinese Customer:  Sales    : sales@Killtest.com  sales@Killtest.net  Support: support@Killtest.com  support@Killtest.com  English    Version  http://www.KillTest.com  Chinese (Traditional)  http://www.KillTest.net  Chinese (Simplified)        http://www.KillTest.cn
/
本文档为【310-055】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索