多选题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
多选题What type of statement is the following equation: y = (m*x)+b?
A. Conditional statement
B. Assignment statement
C. Assertion statement
D. Transfer of control statement
多选题Given: System.out.print(true | false System.out.println(false What will be printed to standard out?
A. true, true
B. true, false
C. false, true
D. false, false
E. Compilation error
多选题Given: public class BooleanResultsOutput {
public static void main(String[] args) { boolean
booleanValue1 = true; boolean booleanValue2 = false;
System.out.print(!(booleanValue1
System.out.print(!(booleanValue1 | !booleanValue2)+" ");
System.out.print(!(booleanValue1 ^ !booleanValue2));
} } What will be printed, considering the
usage of the logical Boolean operators?
A. false, false, true
B. false, true, true
C. true, false, true
D. true, true, true
多选题 Refer to this class for the following two
questions. public class Account { private int
money; public int getMoney() { return
this.money; } public void setMoney(int money)
{ this.money = money; }
}
多选题Given the class FloatNumber and method addHalf, what is the output if
the following code segment is executed? public class
FloatNumber { float number; public
FloatNumber(float number { this.number = number;
} floatgetNumber( { retum
number; } void setNumber(float number)
{ this.number = number; }
} void addHalf(FloatNumber value) {
value.setNumber(value.getNumber()+(value.getNumber()/2f));
} /* CODE SEGMENT */ FloatNumber value = new
FloatNumber(1f); addHalf(value);
System.out.println("value ="+value.getNumber());
A. value = 1
B. value = 1.5
C. value = 2
D. value = 0
多选题You are writing a class that will store the status of an on/off
switch. Which data type is most appropriate for storing this value?
A. boolean
B. char
C. short
D. int
多选题What is the output of the following code segment?
ArrayList <String> sampleArrayList = new ArrayList <String>();
sampleArrayList.add ("One"); sampleArrayList.add
("Two"); sampleArrayList.add (1, "Three");
for(String s : sampleArrayList) { System.out.print(s+"
"); }
A. One Two Three
B. One Three Two
C. Three One Two
D. One Three
E. Three Two
F. A compile time error will be generated.
G. A runtime exception will be thrown.
多选题Which API provides a lightweight solution for GUI components?
A. AWT
B. Abstract Window Toolkit
C. Swing
D. AWT and Swing
