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();
}
}
第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题:
下面程序段的输出结果为( )。 package test; public class ClassA { int x=20: static int y=6; public static void main(String args[]) { ClassB b=new ClassB; go(10); System.out.println("x="+b.x); } } class ClassB { int X; void go(int y) { ClassA a=new ClassA; x=a.Y ; } }
A.x=10
B.x=20
C.x=6
D.编译不通过
第3题:
有以下源程序: package test; public class ClassA { int x=20; static int y=6; public static void main(String args[]) { ClassB b=new ClassB(); b.go(10); System.out.println("x="+b.x); } } class ClassB { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } } 上述源程序文件的运行结果为( )。
A.x=10
B.x=20
C.x=6
D.编译不通过
第4题:
A. 3
B. 4
C.5
D.6
E.7
第5题:
( 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
第6题:
现有: class Top { static int X=l; public Top() { x*=3; } } class Middle extends Top { public Middle() {x+=l; } public static void main(String [] args) { Middle m=new Middle(); System.out.println (x); } } 结果是什么?()
第7题:
class Rectangle { public static void main(String [] args) { int [] x = {1,2,3}; x[1] = (x[1] 〉 1) ? x[2] : 0; System.out.println(x[1]); } } 结果为:()
第8题:
现有: class Top { static int x=l; public Top (inty) { x*=3; } } class Middle extends Top { public Middle() {x+=1; ) public static void main (String [] args) { Middle m = new Middle(); System. out .println (x); } } 结果为:()
第9题:
public class Starter extends Thread { private int x= 2; public static void main(String[] args) throws Exception { new Starter().makeItSo(); } public Starter() { x=5; start(); } public void makeItSo() throws Exception { join(); x=x- 1; System.out.println(x); } public void run() { x *= 2; } } What is the output if the main() method is rum?()
第10题:
0
1
2
Compilation fails.
第11题:
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 */ } }
第12题:
2
3
4
编译失败
第13题:
执行下列代码段之后,x的值为______。 public class ex25 { public static void main(String[] args) { int x=12; int m=x%5; x>>>=m; System.out.println(x); }
A.7
B.3
C.0
D.1
第14题:
下面程序段的输出结果为 package test; public class A { int x=20; static int y=6; public static void main(String args[]) { Class B b=new Class B(); b.go(10); System.out.println(”x=”+b.x); } } class Class B { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } }
A.x=10
B.x=20
C.x=6
D.编译不通过
第15题:
下面程序段的输出结果为 package test; public class Class A { int x=20; static int y=6; public static void main(String args[]) { Class B b=new Class B(); b.go(10); System.out.println("x"+b.x); } } class ClassB { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } }
A.x=10
B.x-20
C.x=6
D.编译不通过
第16题:
以下程序调试结果为:
public class Test {
int m=5;
public void some(int x) {
m=x;
}
public static void main(String args []) {
new Demo().some(7);
}
}
class Demo extends Test {
int m=8;
public void some(int x) {
super.some(x);
System.out.println(m);
}
}
A.5
B.8
C.7
D.无任何输出
E.编译错误
第17题:
interface DeclareStuff{ public static final int EASY = 3; void doStuff(int t); } public class TestDeclare implements DeclareStuff { public static void main(String [] args) { int x=5; new TestDeclare().doStuff(++x); } void doStuff(int s) { s += EASY + ++s; System.out.println(”s “ + s); } } What is the result?()
第18题:
class Super { public int i = 0; public Super(String text) { i = 1; } } public class Sub extends Super { public Sub(String text) { i = 2; } public static void main(String args[]) { Sub sub = new Sub(“Hello”); System.out.println(sub.i); } } What is the result?()
第19题:
class Top { static int x = 1; public Top(int y) { x *= 3; } } class Middle extends Top { public Middle() { x += 1; } public static void main(String [] args) { Middle m = new Middle(); System.out.println(x); } } 结果为:()
第20题:
public class Test { private static int[] x; public static void main(String[] args) { System.out.println(x[0]); } } What is the result?()
第21题:
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?()
第22题:
1
2
3
编译失败
第23题:
s 14
s 16
s 10
Compilation fails.
An exception is thrown at runtime.