站内搜索
OCJP(310-065) 问题列表
问题 多选题Which two statements are true?()AIt is possible for more than two threads to deadlock at once.BThe JVM implementation guarantees that multiple threads cannot enter into a deadlocked state.CDeadlocked threads release once their sleep() method’s sleep duration has expired.DDeadlocking can occur only when the wait(), notify(), and notifyAll() methods are used incorrectly.EIt is possible for a single-threaded application to deadlock if synchronized blocks are used incorrectly.FIf a piece of code is capable of deadlocking, you cannot eliminate the possibility ofdeadlocking by insertinginvocations of Thread.yield().

问题 多选题Given: class ClassA {} class ClassB extends ClassA {} class ClassC extends ClassA {} and: ClassA p0 = new ClassA(); ClassB p1 = new ClassB(); ClassC p2 = new ClassC(); ClassA p3 = new ClassB(); ClassA p4 = new ClassC(); Which three are valid?()Ap0 = p1;Bp1 = p2;Cp2 = p4;Dp2 = (ClassC)p1;Ep1 = (ClassB)p3;Fp2 = (ClassC)p4;

问题 单选题Given: Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbage collection?()A Line 16B Line 17C Line 18D Line 19

问题 单选题Given: Which is true?()A If line 10 is removed, the compilation succeeds.B If line 11 is removed, the compilation succeeds.C If line 12 is removed, the compilation succeeds.D If line 13 is removed, the compilation succeeds.E More than one line must be removed for compilation to succeed.

问题 单选题Given: What is the result?()A No output is produced. 1 2 3B No output is produced. 2 3 4C No output is produced. 1 2 3 4D An exception is thrown at runtime. 1 2 3

问题 单选题Given the following directory structure: bigProject |--source ||--Utils.java| |--classes |-- And the following command line invocation: javac -d classes source/Utils.java Assume the current directory is bigProject,what is the result?()A If the compile is successful, Utils.class is added to the source directory.B The compiler returns an invalid flag error.C If the compile is successful, Utils.class is added to the classes directory.D If the compile is successful, Utils.class is added to the bigProject directory.

问题 单选题Given: What is the result?()A CanadaB null CanadaC Canada nullD Canada CanadaE Compilation fails due to an error on line 26.

问题 单选题A team of programmers is involved in reviewing a proposed design for a new utility class. After some discussion, they realize that the current design allows other classes to access methods in the utility class that should be accessible only to methods within the utility class itself. What design issue has the team discovered?()A Tight couplingB Low cohesionC High cohesionD Loose couplingE Weak encapsulation

问题 单选题Click the Exhibit button. What is the result?()A Compilation of class A fails.B Line 28 prints the value 3 to System.out.C Line 28 prints the value 1 to System.out.D A runtime error occurs when line 25 executes.E Compilation fails because of an error on line 28.

问题 多选题Which two code fragments will execute the method doStuff() in a separate thread?()Anew Thread() {public void run() { doStuff(); }};Bnew Thread() {public void start() { doStuff(); }};Cnew Thread() {public void start() { doStuff(); }}.run();Dnew Thread() {public void run() { doStuff(); }}.start();Enew Thread(new Runnable() {public void run() { doStuff(); }}).start();

问题 单选题A UNIX user named Bob wants to replace his chess program with a new one, but he is not sure where theold one is installed. Bob is currently able to run a Java chess program starting from his home directory /home/bob using the command: java -classpath /test:/home/bob/downloads/*.jar games.Chess Bob’s CLASSPATH is set (at login time) to: /usr/lib:/home/bob/classes:/opt/java/lib:/opt/java/lib/*.jar  What is a possible location for the Chess.class file?()A /test/Chess.classB /home/bob/Chess.classC /test/games/Chess.classD /usr/lib/games/Chess.classE /home/bob/games/Chess.class

问题 多选题Given 11.public interface Status { 12./* insert code here */ int MY_VALUE = 10; 13.} Which three are valid on line 12?()AfinalBstaticCnativeDpublicEprivate

问题 单选题Given: What is the result?()A Compilation fails.B An exception is thrown at runtime.C doStuff x = 6 main x = 6D doStuff x = 6 main x = 7E doStuff x = 7 main x = 6

问题 多选题Given a class whose instances, when found in a collection of objects, are sorted by using the compare To method, which two statements are true?()AThe class implements java.lang.Comparable.BThe class implements java.util.Comparator.CThe interface used to implement sorting allows this class to define only one sort sequence.DThe interface used to implement sorting allows this class to define many different sort sequences.

问题 多选题Given: class ClassA {} class ClassB extends ClassA {} class ClassC extends ClassA {} and: ClassA p0 = new ClassA(); ClassB p1 = new ClassB(); ClassC p2 = new ClassC(); ClassA p3 = new ClassB(); ClassA p4 = new ClassC(); Which three are valid?()Ap0 = p1;Bp1 = p2;Cp2 = p4;Dp2 = (ClassC)p1;Ep1 = (ClassB)p3;Fp2 = (ClassC)p4;