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-056 Exam - Cheat-Test.com

Free 310-056 Sample Questions:

1.Given: 1. interface A { public void aMethod(); } 2. interface B { public void bMethod(); } 3.
interface C extends A,B { public void cMethod(); } 4. class D implements B { 5. public void bMethod(){} 6. } 7. class E extends D implements C { 8. public void aMethod(){} 9. public void bMethod(){} 10. public void cMethod(){} 11. } What is the result?
A.Compilation fails because of an error in line 3.
B.Compilation fails because of an error in line 7.
C.Compilation fails because of an error in line 9.
D.If you define D e = new E(), then e.bMethod() invokes the version of bMethod() defined in Line 5.
E.If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 5.
F.If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 9.
Answer: F

2.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

3.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

4.Which two statements are true? (Choose two.)
A.An encapsulated, public class promotes re­use.
B.Classes that share the same interface are always tightly encapsulated.
C.An encapsulated class allows subclasses to overload methods, but does NOT allow overriding methods.
D.An encapsulated class allows a programmer to change an implementation without affecting outside code.
Answer: A, D

5.Given: 55. int [] x = {1, 2, 3, 4, 5}; 56. int y[] = x; 57. System.out.println(y[2]); Which statement is true?
A.Line 57 will print the value 2.
B.Line 57 will print the value 3.
C.Compilation will fail because of an error in line 55.
D.Compilation will fail because of an error in line 56.
Answer: B

6.Given: 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. } Which code inserted at line 14 causes the foo method to print RED, GREEN, and 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

7.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

9.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

10.A class games.cards.Poker is correctly defined in the jar file Poker.jar. A user wants to execute the main method of Poker on a UNIX system using the command: java games.cards.Poker What allows the user to do this?
A.put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java
B.put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java/*.jar
C.Put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java/Poker.jar
D.put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include /stuff/java
E.put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include /stuff/java/*.jar
F.put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include/stuff/java/Poker.jar
Answer: C

11.Given: 10. class One { 11. public One() { System.out.print(1); } 12. } 13. class Two extends One
{ 14. public Two() { System.out.print(2); } 15. } 16. class Three extends Two { 17. public Three()
{ System.out.print(3); } 18. } 19. public class Numbers{ 20. public static void main( String[] argv )
{ new Three(); } 21. } What is the result when this code is executed?
A.1
B.3
C.123
D.321
E.The code runs with no output.
Answer: C

12.Given: 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. } What is the result?
A.test
B.null
C.An exception is thrown at runtime.
D.Compilation fails because of an error in line 1.
E.Compilation fails because of an error in line 4.
F.Compilation fails because of an error in line 5.
Answer: A

13.Given: 10. public class Bar { 11. static void foo( int... x ) { 12. // insert code here 13. } 14. } Which two code fragments, inserted independently at line 12, will allow the class to compile? (Choose two.)
A.foreach( x ) System.out.println(z);
B.for( int z : x ) System.out.println(z);
C.while( x.hasNext() ) System.out.println( x.next() );
D.for( int i=0; i< x.length; i++ ) System.out.println(x[i]);
Answer: B, D

14.Given a valid DateFormat object named df, and 16. Date d = new Date(0L); 17. String ds = "December 15, 2004"; 18. // insert code here What updates d's value with the date represented by ds?
A.18. d = df.parse(ds);
B.18. d = df.getDate(ds);
C.18. try { 19. d = df.parse(ds); 20. } catch(ParseException e) { };
D.18. try { 19. d = df.getDate(ds); 20. } catch(ParseException e) { };
Answer: C

15.Which three statements concerning the use of the java.io.Serializable interface are true? (Choose three.)
A.Objects from classes that use aggregation cannot be serialized.
B.An object serialized on one JVM can be successfully deserialized on a different JVM.
C.The values in fields with the volatile modifier will NOT survive serialization and deserialization.
D.The values in fields with the transient modifier will NOT survive serialization and deserialization.
E.It is legal to serialize an object of a type that has a supertype that does NOT implement java.io.Serializable.
Answer: B, D, E

16.Given: 1. public class TestString3 { 2. public static void main(String[] args) { 3. // insert code here 5. System.out.println(s); 6. } 7. } Which two code fragments, inserted independently at line 3, generate the output 4247? (Choose two.)
A.String s = "123456789"; s = (s­"123").replace(1,3,"24") ­ "89";
B.StringBuffer s = new StringBuffer("123456789"); s.delete(0,3).replace(1,3,"24").delete(4,6);
C.StringBuffer s = new StringBuffer("123456789"); s.substring(3,6).delete(1,3).insert(1, "24");
D.StringBuilder s = new StringBuilder("123456789"); s.substring(3,6).delete(1,2).insert(1, "24");
E.StringBuilder s = new StringBuilder("123456789"); s.delete(0,3).delete(1,3).delete(2,5).insert(1, "24");
Answer: B E

17.Given: 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");} 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. } What is the result?
A.short LONG
B.SHORT LONG
C.Compilation fails.
D.An exception is thrown at runtime.
Answer: C

18.Given: 11. interface DeclareStuff { 12. public static final int EASY = 3; 13. void doStuff(int t); } 14. public class TestDeclare implements DeclareStuff { 15. public static void main(String [] args) { 16.
int x = 5; 17. new TestDeclare().doStuff(++x); 18. } 19. void doStuff(int s) { 20. s += EASY + ++s; 21. System.out.println("s " + s); 22. } 23. } What is the result?
A.s 14
B.s 16
C.s 10
D.Compilation fails.
E.An exception is thrown at runtime.
Answer: D

19.Given: 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); } What is the result?
A.The file will compile without error.
B.Compilation fails. Only line 7 contains an error.
C.Compilation fails. Only line 12 contains an error.
D.Compilation fails. Only line 13 contains an error.
E.Compilation fails. Only lines 7 and 12 contain errors.
F.Compilation fails. Only lines 7 and 13 contain errors.
G.Compilation fails. Lines 7, 12, and 13 contain errors.
Answer: A


© 2014 Cheat-Test.com, All Rights Reserved