147之真题大讨论!
希望绝顶高手指教!
2. Given: ?
Integer i = new Integer (42);
Long 1 = new Long (42);
Double d = new Double (42.0);
Which two expressions evaluate to True? (Choose Two)
A. (i ==1)
B. (i == d)
C. (d == 1)
D. (i.equals (d))
E. (d.equals (i))
F. (i.equals (42))
Standard Answer: D,E
My Answer: No Answer!
Comment: Different object can't compare each other!
11. Which two demonstrate an “is a” relationship? (Choose Two)
A. public interface Person { }
public class Employee extends Person { } n
B. public interface Shape { }
public class Employee extends Shape { }n
C. public interface Color { }
public class Employee extends Color { }n
D. public class Species { }
public class Animal (private Species species;)
E. interface Component { }
Class Container implements Component (
Private Component[ ] children;
)e
Standard Answer: D,E
My Answer: E
Commend:D is a "Has a " relation!
29. Given:
1. byte [] arry1, array2[];
2. byte array3 [][];
3. byte[][] array4;
If each array has been initialized, which statement will cause a compiler error?
A. array2 = array1;
B. array2 = array3;
C. array2 = array4;
D. both A and B
E. both A and C
F. both B and C
Standard Answer: F
My Answer: A
Commend:byte [] arry1,array2[];is equal to
byte[] arry1;
byte[][] array2;
?55. Which two CANNOT directly cause a thread to stop executing? (Choose Two)
A. Calling the yield method//cannot
B. Calling the wait method on an object//can
C. Calling the notify method on an object//can
D. Calling the NotifyAll method on an object//can
E. Calling the start method on another Thread object//cannot
Standard Answer:A,E
My Answer: E, I am not sure!
Commend: Because yield can cause the thread that has same priority stop!
57. 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)(set X(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 y
C. Check() can return true when multiple threads call setX and setY separately. y
D. Check() can only return true if SyncTest is changed to allow x and y to be set separately. n
bc
Standard Answer: B
My Answer: B,C
Commend:If a thread call setX(0) and another thread call check(),now what is check() return? It is true;
?60. Which two CANNOT directly cause a thread to stop executing? (Choose Two)
A.Existing from a synchronized block
B.Calling the wait method on an object//can
C.Calling notify method on an object//can not
D.Calling read method on an InputStream object//can
E.Calling the SetPriority method on a Thread object//can
Standard Answer: A,C
My Answer:
Commend: 55
???74. Click the exhibit button:
1. public class Mycircle {
2. public double radius;
3. public double diameter;
4.
5. public void setRadius(double radius)
6. this.radius = radius;
7. this.diameter= radius * 2; 8. } 9.
10. public double getRadius() {
11. return radius; 12. } 13. }
Which statement is true?
A. The Mycircle class is fully encapsulated.
B. The diameter of a given MyCircle is guaranteed to be twice its radius. y
C. Lines 6 and 7 should be in a synchronized block to ensure encapsulation.
D. The radius of a MyCircle object can be set without affecting its diameter. y
Standard Answer: B
My Answer: B, D
Commend:Because radius is public,so I can set it without affectiong its diameter.