Free Cheat-test Samples and Demo Questions Download
Adobe exams Adobe
Apple exams Apple
Avaya exams Avaya
Check Point exams Check Point
Cisco exams Cisco
Citrix exams Citrix
CIW exams CIW
CompTIA exams CompTIA
CWNP exams CWNP
EC-Council exams EC-Council
EMC exams EMC
Exin exams Exin
Fortinet exams Fortinet
GIAC exams GIAC
Hitachi exams Hitachi
HP exams HP
IBM exams IBM
Isaca exams Isaca
ISC exams ISC
ISEB exams ISEB
Juniper exams Juniper
LPI exams LPI
McAfee exams McAfee
Microsoft exams Microsoft
Oracle exams Oracle
PMI exams PMI
Riverbed exams Riverbed
SNIA exams SAP
Sun exams SAS
Symantec exams Symantec
VMware exams VMware
All certification exams

Sun 310-055 Exam - Cheat-Test.com

Free 310-055 Sample Questions:

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; }
Answer: 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
Answer: C

3.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.
Answer: C

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?
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.
Answer: 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
Answer: 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.
Answer: 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(); }
Answer: 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.
E.The setCardInformation method breaks encapsulation.
Answer: 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); }
Answer: 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;
Answer: 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.
Answer: 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.
Answer: 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.
C.The code executes and prints "running".
D.The code executes and prints "runningrunning".
E.The code executes and prints "runningrunningrunning".
Answer: E

14.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.
Answer: B

15.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 {
B.public class MinMax {
C.public class MinMax {
D.public class MinMax {
E.public class MinMax {
F.public class MinMax {
Answer: D, F

16.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.
Answer: A

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();
Answer: 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
Answer: A, C, E

19.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.
Answer: D

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.
Answer: D

21.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)
Answer: A, D

22.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();
Answer: A


© 2014 Cheat-Test.com, All Rights Reserved