SCJP - Page -6

51.)
Which two CANNOT directly cause a thread to stop executing? (Choose Two)

a. Calling the yield method.
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 start method on another Thread object.
52.)
Given:

1. public interface Foo {
2. int k = 4;
3. }

Which three are equivalent to line 2? (Choose Three)

a. Final int k = 4;
b. Public int k = 4;
c. Static int k = 4;
d. Private int k = 4;
e. Abstract int k = 4;
f. Volatile int k = 4;
g. Transient int k = 4;
h. Protected int k = 4;
53.)
Which will declare a method that forces a subclass to implement it?

a. Public double methoda();
b. Static void methoda (double d1) {}
c. Public native double methoda();
d. Abstract public void methoda();
e. Protected void methoda (double d1) {}
54.)
Which construct a BufferedInputStream?

a. New BufferedInputStream (“in.txt”);
b. New BufferedInputStream (new File (“in.txt”));
c. New BufferedInputStream (new Writer (“in.txt”));
d. New BufferedInputStream (new InputStream (“in.txt”));
e. New BufferedInputStream (new FileInputStream (“in.txt”));
55.)
Given:

1. public class Foo {
2. private int val;
3. public foo (int v) (val = v;) }
4. public static void main (String [] args) {
5. Foo a = new Foo (10);
6. Foo b = new Foo (10);
7. Foo c = a;
8. int d = 10;
9. double e = 10.0;
10. }
11. }

Which three logical expression evaluate to true? (Choose Three)

a. (a == c)
b. (d == e)
c. (b == d)
d. (a == b)
e. (b == c)
f. (d == 10.0)
56.)
Given:

1. public class foo {
2. public static void main (String [] args) {
3. String s;
4. system.out.println (“s=” + s);
5. }
6. }

What is the result?

a. The code compiles and “s=” is printed.
b. The code compiles and “s=null” is printed.
c. The code does not compile because string s is not initialized.
d. The code does not compile because string s cannot be referenced.
e. The code compiles, but a NullPointerException is thrown when toString is called.
57.)
Given:

1. public class ArrayTest {
2. public static void main (String [] args) {
3. float f1 [ ], f2 [ ];
4. f1 = new float [10];
5. f2 = f1;
6. System.out.println (“f2 [0] =” + f2 [0]);
7. }
8. }

What is the result?

a. It prints f2 [0] = 0.0
b. It prints f2 [0] = NaN
c. An error at line 5 causes compile to fail.
d. An error at line 6 causes compile to fail.
e. An error at line 6 causes an exception at runtime.
58.)
Given:

1. public class SyncTest (
2. private int x;
3. private int y;
4. private synchronized void setX (int i) (x = 1;)
5. private synchronized void setY (int i) (y = 1;)
6. public void setXY (int 1) (setX(i) ; setY(i);)
7. public synchronized Boolean check() (return x != y;)
8.)

Under which conditions will check() return true when called from a different class?

a. Check() can never return true.
b. Check() can return true when setXY is called by multiple threads.
c. Check() can return true when multiple threads call setX and setY separately.
d. Check() can only return true if SybcTest is changed to allow x and y to be set separately.
59.)
Given:

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.println (“baz = “ + baz);
7. }
8. }

And the output:
Baz = 2

Which command line invocation will produce the output?

a. Java Test 2222
b. Java Test 1 2 3 4
c. Java Test 4 2 4 2
d. Java Test 4 3 2 1
60.)
Exhibit:

1. package foo;
2.
3. import java.util.Vector;
4.
5. private class MyVector extends Vector {
6. int i = 1;
7. public MyVector() {
8. i = 2;
9. }
10. }
11.
12. public class MyNewVector extends MyVector {
13. public MyNewVector () {
14. i = 4;
15. }
16. public static void main (String args [] ) {
17. MyVector v = new MyNewVector();
18. }
19. }

The file MyNewVector.java is shown in the exhibit. What is the result?

a. Compilation will succeed.
b. Compilation will fail at line 5.
c. Compilation will fail at line 6.
d. Compilation will fail at line 14.
e. Compilation will fail at line 17.
Find your Self Answer its easy...