SCJP Interview Questions

QUESTION NO 129
Which two create an instance of an array? (Choose Two)
A. int[] ia = new int [15]; B. float fa = new float [20]; C. char[] ca = “Some String”; D. Object oa = new float[20];

E. Int ia [][] = (4, 5, 6) (1, 2, 3)

Answer: A, D

QUESTION NO 130
Given:
1. public class ExceptionTest {
2. class TestException extends Exception {}
3. public void runTest () throws TestException {}
4. public void test () /* Point X*/ {
5. runTest ();
6. }
7. }
At point X on line 4, which code can be added to make the code compile?
A. Throws Exception. B. Catch (Exception e). C. Throws RuntimeException. D. Catch (TestException e). E. No code is necessary.

Answer: B

QUESTION NO 131
Exhibit:
1. public class SwitchTest {
2. public static void main (String []args) {
3. System.out.PrintIn(”value =” +switchIt(4));
4. }
5. public static int switchIt(int x) {
6. int j = 1;
7. switch (x) {
8. case 1: j++;
9. case 2: j++;
10. case 3: j++;
11. case 4: j++;
12. case 5: j++;
13. default:j++;
14. }
15. return j + x;
16. } 17. }
What is the output from line 3?
A. Value = 3 B. Value = 4 C. Value = 5 D. Value = 6 E. Value = 7 F. Value = 8

Answer: F

QUESTION NO 132
Which four types of objects can be thrown using the throw statement? (Choose Four)
A. Error B. Event
C. Object
D. Exception
E. Throwable
F. RuntimeException

Answer: A, D, E, F

QUESTION NO 133
Given:
1. public class ForBar { 2. public static void main(String []args) { 3. int i = 0, j = 5; 4. tp: for (;;) { 5. i ++; 6. for(;;)
7. if(i > –j) break tp; 8. }
9. system.out.printIn(”i = ” + i + “, j = “+ j);
10. }
11. }
What is the result?
A. The program runs and prints “i=1, j=0″ B. The program runs and prints “i=1, j=4″ C. The program runs and prints “i=3, j=4″ D. The program runs and prints “i=3, j=0″ E. An error at line 4 causes compilation to fail. F. An error at line 7 causes compilation to fail.

Answer: A

QUESTION NO 134
Which two can directly cause a thread to stop executing? (Choose Two)
A. Exiting from a synchronized block. B. Calling the wait method on an object. C. Calling the notify method on an object. D. Calling the notifyAll method on an object. E. Calling the setPriority method on a thread object.

Answer: B, E


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

We Will going to send you more Interview Questions & Answers related toSCJP Interview Questions

AddThis Social Bookmark Button

Leave a Reply