|
|

Sun 310-035: Sun Certified Programmer for Java 2 Platform 1.4
|
#1. Given: 1. public class Test { 2. public static void main (String args []) { 3. class Foo { 4. public int i = 3; 5. } 7. Foo foo = (Foo)o; 8. System. out. println(“i = “ + foo. i); 9. } 10. }
What is the result?
|
|
#2. Which two cause a compiler error? (Choose two)
|
|
#3. Given: 11. int i =1,j =10; 12. do { 13. if(i++> --j) { 14. continue; 15. } 16. } while (i <5); 17. System. out. println(“i = “ +i+ “and j = “+j );
What is the result?
|
|
#4. Given: 1. class Test { 2. private Demo d; 3. void start() { 4. d = new Demo(); 5. this.takeDemo(d); 6. } 7. 8. void takeDemo(Demo demo) { 9. demo = null; 10. demo = new Demo(); 11. } 12. }
When is the Demo object, created on line 3, eligible for garbage collection?
|
|
#5. Given: 1. interface Animal { 2. void soundOff(); 3. } 4. 5. class Elephant implements Animal { 6. public void soundOff() { 7. System. out. println(“Trumpet” ); 8. } 9. } 10. 11. class Lion implements Animal { 12. public void soundOff() { 13. System. out. println(“Roar” ); 14. } 15. } 16. 17. class Alpha1 { 18. static Animal get ( String choice ) { 19. if ( choice.equalsIgnoreCase( “meat eater” )) { 20. return new Lion(); 21. } else { 22. return new Elephant(); 23. } 24. } 25. }
Which compiles?
|
|
#6. Which statement is true?
|
|
#7. Given: 1. class A { 2. A() { } 3. } 4. 5. class B extends A { 6. }
Which two statements are true? (Choose two)
|
|
#8. Given: 11. int i = 1,j = 10; 12. do { 13. if(i>j) { 14. break; 15. } 16. j--; 17. } while (++i <5); 18. System. out. println(“i =” +i+” and j = “+j );
What is the result?
|
|
#9. Which statement is true?
|
|
#10. You want a class to have access to members of another class in the same package. Which is the most restrictive access that accomplishes this objective?
|
|
|
|
gen. 0.296
|
Server date 19:26 15-03-2010
|
Developed by Zip © 2006
|
|
 |
|
|