SCJP - Programming Online Tests

SCJP Test 1

Question 1: 1.public class Test { 2.public static void main(String args[]) { 3.class Foo { 4.public int i = 3; } 5.Object o = (Object)new Foo(); 6.Foo foo = (Foo)o; 7.System.out.println(“i = “ + foo.i); } } What is the result ...

10 Comments. 162 views since Feb 19, 2009

SCJP Test 2

Question 1: 1. boolean bool = true; 2. if(bool = false) { 3. System.out.println(“a”); 4. } else if (bool) { 5. System.out.println(“c”); 6. } else if (!bool) { 7. System.out.println(“c”); 8. } else { 9. System.out.println(“d”); 10. } What is the result? ...

3 Comments. 52 views since Feb 21, 2009

SCJP Test - 14

Question 1: Which of the following are valid declarations? Assume java.util.* is imported. A. Vector v; B.Set s; C.Map m; D.Map m; ...

0 Comments. 35 views since Mar 6, 2009

SCJP Test - 6

Question 1: 11. ArraryList a = new ArrayList(); 12. a.add(“Alpha”); 13. a.add(“Bravo”): 14. a.add(“Charlie”); 15. a.add(“Delta”); 16.Iterator iter = a.iterator(); 17. Which two, added at line 17, print the names in the ArrayList in alphabetical order? (Choose two) A. for (int i=0; i< a.size(); i++) System.out.println(a.get(i))); B. for (int i=0; i< a.size(); i++) System.out.println(a[i]); C. while( iter.hasNext() ) System.out.println(iter.next()) ; D. for (int i=0, i< a.size(); i++) System.out.println(iter[i]); E. for (int i=0; i< a.size(); i++) System.out.println(iter.get(i)); ...

0 Comments. 33 views since Mar 1, 2009

SCJP Test - 15

Question 1: 1. public class ReturnIt { 2. return Type methodA(byte x, double y) { 3. return (short)x / y * 2; 4. } 5. } What is the narrowest valid returnType for methodA in line2? ...

2 Comments. 32 views since Apr 4, 2009

SCJP Test 4

Question 1: 11. public void foo( boolean a, boolean b ){ 12. if( a ) { 13. System.out.println( “A” ); 14. } else if ( a && b ) { 15. System.out.println( “A&&B” ); 16. } else { 17. if ( !b ) { 18. System.out.println( “notB” ); 19. } else { 20. System.out.println( “ELSE” ); 21. } 22. } 23. } What is correct? A. If a is true and b is true then the output is “A&&B”. B. If a is true and b is false then the output is “notB”. C. If a is false and b is true then the output is “ELSE”. D. If a is false and b is false then the output is “ELSE”. ...

0 Comments. 27 views since Feb 21, 2009

SCJP Test 3

Question 1: 1. Float f = new Float(“12”); 2. switch (f) { 3. case 12: System.out.println(“Twelve”); 4. case 0: System.out.println(“Zero”); 5. default: System.out.println(“Default”); 6. } What is the result? ...

1 Comments. 25 views since Feb 21, 2009

SCJP Test - 7

Question 1: 1. public class test ( 2. private static int j = 0; 3. 4. private static boolean methodB(int k) ( 5. j += k; 6. return true; 6. ) 7. 8. public static void methodA(int i) { 9. boolean b: 10. b = i < 10 | methodB (4); 11. b = i < 10 || methodB (8); 12. ) 13. 14. public static void main (String args[] } ( 15. methodA (0); 16. system.out.printIn(j); 17. ) 18. ) What is the result? ...

1 Comments. 24 views since Mar 1, 2009

SCJP Test - 9

Question 1: Which statement is true for the class java.util.HashSet? ...

2 Comments. 24 views since Mar 4, 2009

SCJP Test - 10

Question 1: Given an ActionEvent, which method allows you to identify the affected Component? ...

0 Comments. 19 views since Mar 4, 2009

SCJP Test - 8

Question 1: Which will declare a method that forces a subclass to implement it? ...

1 Comments. 18 views since Mar 1, 2009

SCJP Test - 11

Question 1: 1. public class Test { 2. public static void main (String[]args) { 3. String foo = args[1]; 4. String bar = args[2]; 5. String baz = args[3]; 6. System.out.printIn(“baz = ” + baz); 7. } 8. } And the output: Baz = 2 Which command line invocation will produce the output? ...

2 Comments. 18 views since Mar 6, 2009

SCJP Test - 13

Question 1: 1. public class OuterClass { 2. private double d1 1.0; 3. //insert code here 4. } You need to insert an inner class declaration at line2. Which two inner class declarations are valid? (Choose Two) A. static class InnerOne { public double methoda() {return d1;} } B. static class InnerOne { static double methoda() {return d1;} } C. private class InnerOne { public double methoda() {return d1;} } D. protected class InnerOne { static double methoda() {return d1;} } E. public abstract class InnerOne { public abstract double methoda(); } ...

1 Comments. 17 views since Mar 6, 2009

SCJP Test - 5

Question 1: 1. public class Test { 2. public static void add3 (Integer i) { 3. int val = i.intValue(); 4. val += 3; 310 - 035 Leading the way in IT testing and certification tools, www.testking.com -51 - 5. i = new Integer(val); 6. } 7. 8. public static void main(String args[]) { 9. Integer i = new Integer(0); 10. add3(i); 11. System.out.println(i.intValue()); 12 } 13 } What is the result? ...

0 Comments. 17 views since Mar 1, 2009

SCJP Test - 12

Question 1: 1. public class X implements Runnable( 2. private int x; 3. private int y; 4. 5. public static void main(String[]args) 6. X that = new X(); 7. (new Thread(that)).start(); 8. (new Thread(that)).start(); 9. ) 10. 11. public void run() ( 12. for (;;) ( 13. x++; 14. y++; 15. System.out.printIn(“x=” + x + “, y = ” + y); 16. ) 17. ) 18. ) What is the result? A. B. C. D. (for example, “x=1, y=1”. In addition, each value appears only for once (for example, “x=1, y=1” followed by “x=2, y=2”). ...

0 Comments. 14 views since Mar 6, 2009