D) int i = 1; int j = 2;
if (i == 1 & | j == 2) { System.out.println(\
}
20、{Java题目}下列代码执行的结果是( )(选择1项) public class text {
public static void main(String[] args) { int x= 1, y = 6; while (y--==6) {x--;}
System.out.println(\ } }
A)程序能运行,输出结果:x=0,y=5 B)程序能运行,输出结果:x=-1,y=4 C)程序能运行,输出结果:x=0,y=4 D)程序不能编译 21、 class Super {
public Integer getLenght() { return new Integer(4); } }
public class Sub extends Super {
public Long GetLenght() { return new Long(5); } public static void main(String[] args) { Super sooper = new Super(); Sub sub = new Sub(); System.out.println(
sooper.getLenght().toString() + \ sub.getLenght().toString() );
} }
程序运行的结果是什么?()(选择1项)
A. 4,4 B. 4,5 C. 5,4 D. 5,5 22、 ClassOne.java: package com.abe.pkg1; public class ClassOne {
private char var = 'a'; char getVar() { return var; } }
ClassTest.java: package com.abe.pkg2; import com.abc.pkg1.ClassOne;
E.编辑失败 public class ClassTest extends ClassOne { } }
运行结果是什么?() (选择1项)
A.编译失败
B.编译成功,没有异常抛出
C.在ClassTest.java的第5行有异常抛出 D.在ClassTest.java的第6行有异常抛出 23、
public class Foo {
public static void main(String[] args) {
try {
System.out.println( \
System.exit(0); } catch(Exception e) { System.out.println(“---”); }finally{
System.out.println( \
public static void main(String[] args) {
char a = new ClassOne().getVar(); char b = new ClassTest().getVar();
}
} }
程序的运行结果是什么?()(选1项)
A.Hello
B. Hello --- World! C.没有输出内容 D. 编译失败 24、 class A {
final public int method1(int a, int b) {return 0; } }
class B extends A {
public int method1(int a, int b) { return 1; } }
public class Test {
public static void main(Strings args[]) { } }
B b;
System.out.println(\
运行结果是什么?()(选择1项)
A. x = 0 B. x = 1 C.编辑失败 D.抛出运行时异常
25、下面哪几条语句可以在接口中定义?()A. void methoda(); B. public double methoda(); C. public final double methoda(); D. static void methoda(double d1); E. protected void methoda(double d1); 26、 class Base {
Base() { System.out.print(\ }
public class Alpha extends Base { public static void main( String[] args ) { new Alpha();
new Base();