多选题You need to create an application that is used to calculate the
attendance at a baseball game. What data type would be most appropriate for
storing the attendance?
A. boolean
B. char
C. float
D. int
多选题Which package contains the Java Collections Framework?
A. java.io
B. java.net
C. java.util
D. java.utils
多选题Which statements correctly declare boolean variables?
A. Boolean isValid = true;
B. boolean isValid = TRUE;
C. boolean isValid = new Boolean(true);
D. boolean isValid = 1;
多选题What constructor is equivalent to the one listed here?
public SampleConstructor( {
System.out.println("SampleConstructor"); }
A. public SampleConstructor() { this();
System.out.println("Sample Constructor"); }
B. public SampleConstructor() { super();
System.out.println("Sample Constructor"); }
C. public SampleConstructor() { this.SampleConstructor();
System.out.println("Sample Constructor"); }
D. public SampleConstructor() {
super.SampleConstructor(); System.out.println("Sample
Constructor"); }
E. None of the above
多选题When instantiating an object with generics, should angle brackets, box
brackets, parentheses, or double-quotes be used to enclose the generic type?
Select the appropriate answer.
A. List <Integer> a = new ArrayList <Integer> ();
B. List [Integer] a = new ArrayList [Integer] ();
C. List {Integer} a = new ArrayList {Integer} ();
D. List "Integer" a = new ArrayList "Integer" ();
多选题Given: public class EqualityTests {
public static void main (String[] args) Integer value1 = new
Integer("312"); Integer value2 = new Integer ("312");
Object object1 = new Object(); Object object2 = new
Object(); Object object3 = value1; }
} Which expressions evaluate to true?
A. value1.equals (value2)
B. value1.equals (object1)
C. value1.equals (object3)
D. object1.equals (object2)
多选题What best describes the result of the following code segment? The
ArrayList sampleArrayList has already been declared and initialized.
int i = 63; sampleArrayList.add(i);
A. The int is successfully placed into the ArrayList.
B. The int is converted to an Integer via autoboxing and then placed into
the ArrayList.
C. null is placed into the ArrayList.
D. A compile time error will be generated.
E. A runtime exception will be thrown.
多选题 Use the following code example for the next four
questions: public class Client { Address
address; AccountNum[] accountNums; void
setAddress(Address newAddress) { address =
newAddress; } public Client() {
accountNums = new AccountNum[2]; accountNums[0] = new
AccountNum(); accountNums[1] = new AccountNum();
} }
多选题Given: public class ArithmeticResultsOutput
{ public static void main(String[] args) { int
i = 0; int j = 0; if(i++ == ++j)
System.out.println("True: i="+i+"'j="+j); } else
{ System.out.println("False: i="+i+"'j="+j);
} } } What will be printed to
standard out?
A. True: i=0, j=1
B. True: i=1, j=1
C. False: i=0, j=1
D. False: i=1, j=1
多选题Given the following Java code segment, what will be printed,
considering the usage of the modulus operators?
System.out.print(49 % 26 % 5 % 1);
A. 23
B. 3
C. 1
D. 0
多选题Which command-line usages appropriately set a system property value?
A. java -Dcom.ocajexam.propertyValue=003 MainClass
B. java -d com.ocajexam.propertyValue=003 MainClass
C. java -prop com.ocajexam.propertyValue=003 MainClass
D. java -D:com.ocajexam.propertyValue=003 MainClass
多选题Which statement is false about the toString method?
A. The toString method is a method of the Object class.
B. The toString method returns a string representation of the object.
C. The toString method must return the object's state information in the
form of a string.
D. The toString method is commonly overridden.
多选题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
