多选题Given the following line of code, what lines below are valid? (Choose
all that apply.) enum Sports {FOOTBALL, BASKETBALL, BASEBALL,
TRACK}
A. Sports sport = FOOTBALL;
B. Sports sport = Sports.FOOTBALL;
C. Sports sport = Sports.HOCKEY;
D. Sports sport = 'TRACK'
多选题Which of the following statements will not compile?
A. if(true);
B. if(true) {}
C. if(true) {;}
D. if(true) {;;}
E. if(true); {};
F. All statements will compile.
多选题What is the value of the variable sum at the end of this code segment?
int[][] square=new int[3][3];
for(int i=0;i<3;i++) {
square[i][i]=5;
}
int sum=0;
for(int i=0;i<3;i++) {
for(int j=0;j<3;j++) {
sum+=square [i][j];
}
}
A. 0
B. 5
C. 10
D. 15
E. 20
F. 25
G. 30
H. 35
I. 40
J. 45
K. 50
L. It will generate a compiler error.
多选题What is the result of using a method of an uninitialized object?
A. Null is returned.
B. The object is automatically initialized and an appropriate value is
returned.
C. A NullPointerException is thrown from the Java Virtual Machine.
多选题Given: System.out.print(3+3+"3");
System.out.print("and"); System.out.println("3"+3+3);
What will be printed to standard out?
A. 333 and 333
B. 63 and 63
C. 333 and 63
D. 63 and 333
多选题What lines will compile without errors? (Choose all that apply.)
A. Object obj = new Object();
B. Object[] obj = new Object();
C. Object obj[] = new Object();
D. Object[] obj = new Object[];
E. Object[] obj = new Object[3]();
F. Object[] obj = new Object[7];
G. Object obj[] = new Object[];
H. Object obj[] = new Object[3]();
I. Object obj[] = new Object[7];
J. Object[8] obj = new Object[];
K. Object[3] obj = new Object[3]();
L. Object[7] obj = new Object[7];
M. Object obj[] = new {new Object(), new Object()};
N. Object obj[] = {new Object(), new Object()};
O. Object obj[] = {new Object[1], new Object[2]};
多选题Static methods have access to which of the following? (Choose all that
apply.)
A. Static variables
B. Instance variables
C. Standard methods
D. Static Methods
E. None of the above
多选题When apply naming conventions, which Java elements should start with a
capital letter and continue on using the camel case convention?
A. Class names
B. Interface names
C. Constant names
D. Package names
E. All of the above
多选题定义如下的二维数组b,下面的说法正确的是( )。 int b[][]=1, 2, 3, 4, 5,6, 7, 8; A.b.length的值是3。 B.b[1].length的值是3。 C.b[1][1]的值是5。 D.二维数组b的第一行有3个元素
多选题The for loop has been enhanced in Java 5.0. Which is not a common term
for the improved for loop?
A. The for in loop
B. The specialized for loop
C. The for each loop
D. The enhanced for loop
多选题Which two import statements will allow for the import of the HashMap
class?
A. import java.util.HashMap;
B. import java.util.*;
C. import java.util.HashMap.*;
D. import java.util.hashMap;
多选题What is the effect of the following line of code?
super()
A. The method that is overridden by the current method is called.
B. The parent class's constructor is called.
C. The current class's constructor is called.
D. The child class's constructor is called
E. The current method is recursively called.
多选题Given the SampleClass, what is the output of this code
segment? SampleClass s = new SampleClass();
s.sampleMethod(4.4, 4); public class SampleClass {
public void sampleMethod(int a, double b) {
System.out.println("Method 1"); } public void
sampleMethod(double b, int a) { System.out.println("Method
2"); } }
A. Method 1
B. Method 2
C. Method 1 Method 2
D. Method 2 Method 1
E. Compiler error
多选题Given:
String name1 = new String("Benjamin");
StringBuilder name2 = new StringBuilder("Benjamin");
System.out.println(name2.equals(name1));
Are the String and StringBuilder classes of comparable types? Select the correct statement.
A. The String and StringBuilder classes are comparable types.
B. The String and StringBuilder classes are incomparable types.
多选题Considerthefollowingillustration.Whatproblemexistswiththepackaging?YoumaywishtoreferenceAppendixGontheUnifiedModelingLanguage(UML)forassistance.A.Youcanhaveonlyoneclassperpackage.B.Packagescannothaveassociationsbetweenthem.C.Packagecom.ocajexam.backing_beansfailstomeettheappropriatepackagingnamingconventions.D.PackageCOM.OCAJEXAM.UTILSfailstomeettheappropriatepackagingnamingconventions.
多选题What is the output of the following code segment?
String[] numbers = {"One", "Two", "Three"};
System.out.println(numbers[3]+" "+numbers[2]+" "+ numbers[1]);
A. One Two Three
B. Three Two One
C. A compile time error will be generated.
D. A runtime exception will be thrown.
多选题下面哪些关键字能用来控制对类成员的访问( )? A.public B.protected C.private D.default
多选题Given the following line of code, which of the lines of code listed
are incorrect? (Choose all that apply.) char c;
A. c = new char();
B. c = 'Y';
C. c = '/u0056';
D. c = "Yes";
多选题The following code segment is valid. True or false?
int[][] square = new int[2][];
square[0] = new int[5];
square[1]=new int[3];
A. True
B. False
多选题Which keyword is part of a transfer of control statement?
A. if
B. return
C. do
D. assert
