JAVA试题英文版(答案)
一.Which two demonstrate an “is a” relationship? (Choo Two)
A. public interface Person { }//语法错了
public class Employee extends Person { }
B. public interface Shape { }//语法错了
public class Employee extends Sha pe { }
C. public interface Color { }//语法错了
public class Employee extends Color { }
D. public class Species { }水龙头漏水
public class Animal{private Species species;}
E. interface Component { }
Class Container implements Component (
Private Component[ ] children;
二.which statement is true?
如何游泳A. An anonymous inner class may be declared as final
B. An anonymous inner class can be declared as private
C. An anonymous inner class can implement mutiple interfaces
D. An anonymous inner class can access final variables in any enclosing scope (不能)
E. Construction of an instance of a static inner class requires an instance of the encloing outer class
构造一个静态的内部类对象需要构造包含它的外部类的对象
三. Given:
1. package foo;
2.
3. public class Outer (
4. public static class Inner (
5. )
6. )
Which statement is true?
A. An instance of the Inner class can be constructed with “new Outer.Inner ()”
B. An instance of the inner class cannot be constructed outside of package foo
他们都是public的,只要在外部import就行
C. An instance of the inner class can only be constructed from within the outer
class
D.From within the package bar, an instance of the inner class can be constructed with “new inner()”
四.Exhibit(展览、陈列):
1 public class enclosinggone{
2 public class insideone{}
3 }祝福的句子
4 public class inertest{
5 public static void main (String[] args){
6 enclosingone eo = new enclosingone();
7 //inrt code here
8 }
}淘宝新店
Which statement at line 7 constructs an instance of the inner class?
A. InsideOne ei = eo.new InsideOne(); 写程序试出来
B. Eo.InsideOne ei = eo.new InsideOne();
李斯韩非C InsideOne ei = w InsideOne();
D.EnclosingOne InsideOne ei = eo.new InsideOne();
五.
1) interface Foo{
2) int k=0;
3) }
4) public class Test implements Foo{
5) public static void main(String args[]){
6) int i;
7) Test test =new Test();
8) i=test.k;
9) i=Test.k;
10) i=Foo.k;
11) }
12) }
点头英文
What is the result?
A. Compilation succeeds.
B. An error at line 2 caus compilation to fail.
C. An error at line 9 caus compilation to fail.
D. An error at line 10 caus compilation to fail.
E. An error at line 11 caus compilation to fail.
六.
//point X
public class Foo{
public static void main(String[] args){
PrintWriter out=new PrintWriter(new
java.io.OutputStreamWriter(System.out),true);
out.println("Hello");
}
}
which statement at point X on line 1 allows this code to compile and run?
欧阳修代表作品在point X这个位置要填入什么代码才能使程序运行
A.import java.io.PrintWriter
B.include java.io.PrintWriter
C.import java.io.OutputStreamWriter
D.include java.io.OutputStreamWriter
E.No statement is needed
本来两个都要import,但是后者OutputStreamWriter指定了包结构
java.io.OutputStreamWriter
七.what is rerved words in java? 保留字而非关键字
A. run
B.default
C. implement
D. import
八. which three are valid declaraction of a float?
(float作为整数是可以的,其余几个都是double)
A. float foo=-1;
B. float foo=1.0;
C. float foo=42e1;
.
D. float foo=2.02f;
E. float foo=3.03d;
F. float foo=0x0123;
九. Given:
8. int index = 1;
9. boolean[] test = new boolean[3]; (数组作为对象缺省初始化为fal)
10. boolean foo= test [index];
What is the result?
A. foo has the value of 0
B. foo has the value of null
C. foo has the value of true
D. foo has the value of fal
E. an exception is thrown
F. the code will not compile