Given a method that must ensure that its parameter is not null:
11. public void someMethod(Object value) {
12. // check for null value
...
20. System.out.println(value.getClass());
21. }
What inserted at line 12, is the appropriate way to handle a null value?()
A.assert value == null;
B.assert value != null, "value is null";
C.if (value == null) { throw new AssertionException("value is null"); }
D.if (value == null) { throw new IllegalArgumentException("value is null"); }
您可能感兴趣的试卷
你可能感兴趣的试题
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 coupling
B.Low cohesion
C.High cohesion
D.Loose coupling
E.Weak encapsulation
Given:
11.double input = 314159.26;
12.NumberFormat nf = NumberFormat.getInstance(Locale.ITALIAN);
13.String b;
14.//insert code here
Which code, inserted at line 14, sets the value of b to 314.159,26?()
A.b = nf.parse( input );
B.b = nf.format( input );
C.b = nf.equals( input );
D.b = nf.parseObject( input );
Given:
If an instance of class Beagle is created,then Serialized,then deSerialized, what is the result?()
A.ad
B.ada
C.add
D.adad
Given:
11.String test = "This is a test";
12.String[] tokens = test.split("\s");
13.System.out.println(tokens.length);
What is the result?()
A.0
B.1
C.4
D.Compilation fails.
Given that c is a reference to a valid java.io.Console object, and:
11.String pw = c.readPassword("%s", "pw: ");
12.System.out.println("got " + pw);
13.String name = c.readLine("%s", "name: ");
14.System.out.println(" got ", name);
If the user types fido when prompted for a password, and then responds bob when prompted for a name,what is the result?()
A.An exception is thrown at runtime
B.pw: fido got fido name: bob got bob
C.pw: got fido name: bob got bob
D.Compilation fails.
A.When using versions of Java technology earlier than 5.0.
B.When sharing a StringBuffer among multiple threads.
C.When using the java.io class StringBufferInputStream.
D.When you plan to reuse the StringBuffer to build more than one string.
Given:
12.Date date = new Date();
13.df.setLocale(Locale.ITALY);
14.String s = df.format(date);
The variable df is an object of type DateFormat that has been initialized in line 11.
What is the result if this code is run on December 14, 2000?()
A.The value of s is 14-dic-2000.
B.The value of s is Dec 14, 2000.
C.An exception is thrown at runtime.
D.Compilation fails because of an error in line 13.
Given:
What is the result?()
A.int Long
B.Short Long
C.Compilation fails.
D.An exception is thrown at runtime.
Given:
Which statement is true?()
A.Compilation fails.
B.An exception is thrown at runtime.
C.Synchronizing the run() method would make the class thread-safe.
D.The data in variable "x" are protected from concurrent access problems.
E.Declaring the doThings() method as static would make the class thread-safe.
Given that Triangle implements Runnable, and:
Which two statements, inserted independently at both lines 35 and 41, tend to allow both threads totemporarily pause and allow the other thread to execute?()
A.Thread.wait();
B.Thread.join();
C.Thread.yield();
D.Thread.sleep(1);
E.Thread.notify();
最新试题
Click the Exhibit button.Which graph represents the correct directory structure for a JAR file from which those classes can be used by the compiler and JVM?()
Given:What is the result?()
Given:What is the result?()
Given:What is the result?()
Given:What is the result?()
A programmer has an algorithm that requires a java.util.List that provides an efficient implementation of add(0, object), but does NOT need to support quick random access.What supports these requirements?()
Given a correctly compiled class whose source code is:Assume that the class file is located in /foo/com/sun/sjcp/, the current directory is /foo/, and that theclasspath contains "." (current directory).Which command line correctly runs Commander?()
Given a method that must ensure that its parameter is not null:What, inserted at line 12, is the appropriate way to handle a null value?()
Given:Which command-line invocations will compile?()
Given:What are four valid examples of polymorphic method calls?()