多选题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.
填空题线程的优先级在______至______之间,数值越大______。
填空题创建一个名为 MyPackage 的包的语句是______,该语句应该放在程序的位置为:______。
填空题在一个时间只能由一个线程访问的资源称为______。访问临界资源的代码______。
填空题构造方法是一种特殊的成员方法,构造方法名与______相同。
填空题按要求填空 abstract class SuperAbstract void a()… abstract void b(); abstract int c(int i); interface AsSuper void x(); abstract class SubAbstract extends SuperAbstract implements AsSuper public void b()… abstract String f(); public class InheritAbstract extends SubAbstract public void x()… public int c(int i ) … public String f()… public static void main(String args[]) InheritAbstract instance=new InheritAbstract(); instance.x(); instance.a(); instance.b(); instance.c(100); System.out.println(instance.f()); 在以上这段程序中: 抽象类有:SuperAbstract和 (1) (写出类名) 非抽象类有: (2) (写出类名) 接口有: (3) (写出接口名) AsSuper中的x()方法是(4)方法,所以在InheritAbstract中必须对它进行(5)
填空题按注释完成程序 public class Leaf private int i = 0; //此属性值用于检验 Leaf increment() //定义方法increment(),返回值是Leaf类的对象 i++; return (1) ;//将当前对象的地址作为返回值返回 void print() System.out.println(" i = " + i); public static void main(String args[]) Leaf x = (2); //创建Leaf类的对象x x.increment().increment().increment().print(); //多次调用方法increment(),返回的都是x的地址,i 值表示调用次数 输出结果为 i = (3)
填空题Java语言只允许单继承,指每个类只能有一个______。
填空题如果一个Java Applet源程序文件只定义有一个类,该类的类名为MyApplet,则类MyApplet必须是______类的子类并且存储该源程序文件的文件名为______。