a.wait();
t.wait();
t.join();
t.yield();
t.notify();
a.notify();
t.interrupt();
第1题:
在下面程序的下画线处应填入的选项是 public class Test______{ public static void main(String args[]) { Test t=new Test(); Thread tt=new Thread(t); tt.start(); } public void run() { for(int i=0;i<5;i++) System.out.println("i="+i); } }
A.implements Runnable
B.extends Thread
C.implements Thread
D.extends Runnable
第2题:
interface A{
int x = 0;
}
class B{
int x =1;
}
class C extends B implements A {
public void pX(){
System.out.println(x);
}
public static void main(String[] args) {
new C().pX();
}
}
错误。在编译时会发生错误(错误描述不同的JVM 有不同的信息,意思就是未明确的
x 调用,两个x 都匹配(就象在同时import java.util 和java.sql 两个包时直接声明Date 一样)。
对于父类的变量,可以用super.x 来明确,而接口的属性默认隐含为 public static final.所以可
以通过A.x 来明确。
第3题:
( 30 )在程序的下划线处应填入的选项是
public class Test _________{
public static void main(String args[]){
Test t = new Test();
Thread tt = new Thread(t);
tt.start();
}
public void run(){
for(int i=0;i<5;i++){
system.out.println( " i= " +i);
}
}
}
A ) implements Runnable
B ) extends Thread
C ) implements Thread
D ) extends Runnable
第4题:
1. public interface A { 2. public void doSomething(String thing); 3. } 1. public class AImpl implements A { 2. public void doSomething(String msg) { } 3. } 1. public class B { 2. public A doit() { 3. // more code here 4. } 5. 6. public String execute() { 7. // more code here 8. } 9. } 1. public class C extends B { 2. public AImpl doit() { 3. // more code here 4. } 5. 6. public Object execute() { 7. // more code here 8. } 9. } Which statement is true about the classes and interfaces in the exhibit?()
第5题:
Given: 1. public class Method Over { 2. public void set Var (int a, int b, float c) { 3. } 4. } Which two overload the set Var method()?
第6题:
Given the following interface definition, which definitions are valid?() interface I { void setValue(int val); int getValue(); } DEFINITION a: (a) class a extends I { int value; void setValue(int val) { value = val; } int getValue() { return value; } } DEFINITION b: (b) interface b extends I { void increment(); } DEFINITION c: (c) abstract class c implements I { int getValue() { return 0; } abstract void increment(); } DEFINITION d: (d) interface d implements I { void increment(); } DEFINITION e: (e) class e implements I { int value; public void setValue(int val) { value = val; } }
第7题:
1. public class test ( 2. public static void main(string args[]) { 3. int 1= 0; 4. while (i) { 5. if (i==4) { 6. break; 7. } 8. ++i; 9. } 10. 11. } 12. ) What is the value of i at line 10?()
第8题:
public class Session implements Runnable, Clonable{ public void run ();public Object clone () ; }
public class Session extends Runnable, Cloneable { public void run() {/*dosomething*/} public Object clone() {/*make a copy*/} }
public abstract class Session implements Runnable, Clonable { public void run() {/*do something*/} public Object clone() {/*make a copy*/} }
public class Session implements Runnable, implements Clonable { public void run() {/*do something*/} public Object clone() {/*make a copy*/} }
第9题:
Compilation succeeds.
An error at line 2 causes compilation to fail.
An error at line 9 causes compilation to fail.
An error at line 10 causes compilation to fail.
An error at line 11 causes compilation to fail.
第10题:
Value is: 8
Compilation fails.
Value is: 12
Value is: -12
The code runs with no output.
An exception is thrown at runtime.
第11题:
0
1
2
3
第12题:
1
2
3
4
第13题:
若类A和类B的定义如下: class A { int i,j; public: int geti() { return i; } }; class B: public A { int k; public: void make() { k=i*j } }; 则上述定义中
A.k=i*j;
B.int k;
C.return i;
D.void make()
第14题:
下列关于Test类的定义中,正确的是( )。
A.class Test implements Runnable{ public void run{} Dublic void someMethod[]{} }
B.class Test implements Runnable( puIblic void run; }
C.class Test implements Runnable( Dublic void someMethod[]; }
D.class Test implements Runnable( public void someMethod{} }
第15题:
1. public class Target { 2. private int i = 0; 3. public int addOne() { 4. return ++i; 5. } 6. } And: 1. public class Client { 2. public static void main(String[] args) { 3. System.out.println(new Target().addOne()); 4. } 5. } Which change can you make to Target without affecting Client?()
第16题:
interface Data { public void load(); } abstract class Info { public abstract void load(); } Which class correctly uses the Data interface and Info class?()
第17题:
下列代码正确的是哪项?()
第18题:
Given: 1. public class ConstOver { 2. public constOver(int x, int y, int z) { 3. } 4. } Which two overload the ConstOver Constructor?()
第19题:
public abstract class Shape { private int x; private int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y; } } Which two classes use the Shape class correctly?()
第20题:
public class Employee extends Info implements Data { public void load() { /*do something*/ } }
public class Employee implements Info extends Data { public void load() { /*do something*/ } }
public class Employee extends Info implements Data { public void load() { /*do something */ } public void Info.load() { /*do something*/ } }
public class Employee implements Info extends Data { public void Data.load() { /*dsomething */ } public void load() { /*do something */ } }
public class Employee implements Info extends Data { public void load() { /*do something */ } public void Info.load(){ /*do something*/ } }
public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ } public void Info.load() { /*do something*/ } }
第21题:
public class Circle implements Shape { private int radius; }
public abstract class Circle extends Shape { private int radius; }
public class Circle extends Shape { private int radius; public void draw(); }
public abstract class Circle implements Shape { private int radius; public void draw(); }
public class Circle extends Shape { private int radius;public void draw() {/* code here */} }
public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }
第22题:
ConstOver() {}
protected int ConstOver(){}
private ConstOver(int z, int y, byte x ) {}
public Object ConstOver(Int x, int y, int z) {}
pubic void ConstOver (byte x, byte y, byte z) {}
第23题:
a.wait();
t.wait();
t.join();
t.yield();
t.notify();
a.notify();
t.interrupt();