多选题Which declaration of the StringBuilder class exists?
A. public StringBuilder reverse(String str) {...}
B. public StringBuilder reverse(int index, String str) {...}
C. public StringBuilder reverse() {...}
D. All of the above
多选题What is the correct way to initialize a variable declared with the
data type of Book , as a new Book object?
A. Book b;
B. Book b = new Book();
C. Book b = new Book[];
D. Book b = Book();
多选题What can be stored in an ArrayList?
A. Primitives
B. Objects
C. Standard arrays
D. Enums
多选题The new keyword is used to initialize which of the following data
types? (Choose all that apply.)
A. Object
B. boolean
C. Boolean
D. Float
E. float
F. float[]
多选题A system has three sensors attached to it. You need a way to represent
this system in your program. What would be the best data type to use to model
this system and sensors?
A. Object
B. boolean
C. enum
D. int
多选题What is wrong with the following code segment? (Choose all that apply.)
1: float a = 1.2f;
2: int b = 5;
3: short c = 9;
4: long d = 6;
5: double e = b;
6: Double f = e;
7: Short g;
8: Float h = g.floatValue();
A. Nothing is wrong.
B. There is an error on line 1.
C. There is an error on line 2.
D. There is an error on line 3.
E. There is an error on line 4.
F. There is an error on line 5.
G. There is an error on line 6.
H. There is an error on line 7.
I. There is an error on line 8.
多选题When organizing the elements in a class, which order is preferred?
A. Data members, methods, constructors
B. Data members, constructors, methods
C. Constructors, methods, data members
D. Constructors, data members, methods
E. Methods, constructors, data members
多选题What Java-related features are new to J2SE 5.0?
A. Static imports
B. package and import statements
C. Autoboxing and unboxing
D. The enhanced for loop
多选题What is the best data type to use if you are required to perform many
addition, subtraction, and multiplication calculations on a whole number?
A. double
B. Double
C. int
D. Integer
多选题下面说法正确的是______。 A.final 可修饰类、属性(变量)、方法。 B.abstract可修饰类、方法。 C.抽象方法只有方法头,没有方法体。 D.关键字final和abstract不能同时使用。
多选题关于BufferedReader类的readLine______方法,以下说法正确的是()。 A.方法readLine( )每次读取一行数据。 B.方法readLine( )每次读取一个字节。 C.该方法可能抛出IOException异常,调用该方法时通常应将它放到try块中,并通过catch块处理异常。 D.如果读到流的末尾,该方法返回的结果为null。
多选题What is the value of variable x in the following code
segment? float x =O.Of; int y = 5;
long z; x = y + 3.3f; x = x+z;
A. 0
B. 0.0f
C. 5.0f
D. 8.3f
E. 8.3
F. This code will not compile.
多选题You have decided on the data type for a variable that will store the
information about the on/off switch. Now you must determine a name for it. Which
of the following names follows the Java naming conventions?
A. LIGHTSWITCHENABLED
B. LightSwitchEnabled
C. lightSwitchEnabled
D. x
多选题Which usage represents a valid way of compiling a Java class?
A. java MainClass.class
B. javac MainClass
C. javac MainClass.source
D. javac MainClass.java
多选题Given the SampleClass, what is the output of this code
segment? SampleClass sampleClass = new SampleClass();
public class SampleClass { private int size;
private int priority; public SampleClass() {
super(); System.out.println("Using default
values"); } public SampleClass(int size)
{ this.size = size;
System.out.println("Setting size"); } public
SampleClass(int priority) { this.priority = priority;
System.out.println("Setting priority"); }
}
A. Using default values
B. Setting size
C. Setting priority
D. Compiler error
多选题In the following line of code, what does the (int)
represent? number = (int)sensorReading;
A. Rounding the sensorReading variable to the nearest int.
B. Casting the sensorReading variable to the int data type.
C. Nothing; it is there as a comment.
多选题Which two command-line usages appropriately identify the classpath?
A. javac -cp/project/classes/MainClass.java
B. javac -sp/project/classes/MainClass.java
C. javac -classpath/project/classes/MainClass.java
D. javac -classpaths/project/classes/MainClass.java
多选题Given the following code segment: public void
validatePrime() { long p = 17496; //'prime number'
candidate Double primeSquareRoot = Math.sqrt(p);
boolean isPrime = true; for(long j = 2; j<=
primeSquareRoot.longValue(); j++) { if(p % j = = 0) {
// Print divisors
System.out.println(j+"X"+p/j); isPrime = false;
} } System.out.println("Prime number:
"+isPrime); } Which of the following is true?
Hint: 17496 is not a prime number.
A. The code will not compile due to s syntactical error somewhere in the
code.
B. The code will not compile since the expression (p % j == 0) should be
written as ((p % j) == 0).
C. Divisors will be printed to standard out (for example, 2x8478, and so
on), along with Prime number: false as the final output.
D. Divisors will be printed to standard out (for example, 2x8478, and so
on), along with "Prime number: 0" as the final output.
多选题The Java Basic I/O API contains what types of classes and interfaces?
A. Internationalization
B. RMI, JDBC, and JNDI
C. Data streams, serialization, and file system
D. Collection API and data streams
多选题Consider the interface CharSequence that is a required argument in one
of the replace method declarations: public String
replace(CharSequence target, CharSequence replacement) {
... } This CharSequence interface is a super
interface to which concrete classes?
A. String
B. StringBoxer
C. StringBuffer
D. StringBuilder
