A. 输出:value is 99.99
B. 输出: value is 9
C. 输出: value is 9.0
D. 在第4行出现编译错误
第1题:
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 来明确。
第2题:
编译运行以下程序后,关于输出结果的说明正确的是( )。 public class Conditional{ public static void main (String args[]){ int x=2: System.out.println("value is”+ ((x<1)?2:2)); } }
A.输出结果为:valueis22.2
B.输出结果为:value is 2
C.输出结果为:value is 2.0
D.编译错误
第3题:
A. 3
B. 4
C.5
D.6
E.7
第4题:
以下程序调试结果为:
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.编译错误
第5题:
1. public class Test { 2. public static void main (String args) { 3. unsigned byte b = 0; 4. b--; 5. 6. } 7. } What is the value of b at line 5?()
第6题:
1. public class X { 2. public static void main (String[]args) { 3. int [] a = new int [1] 4. modify(a); 5. System.out.printIn(a[0]); 6. } 7. 8. public static void modify (int[] a) { 9. a[0] ++; 10. } 11. } What is the result?()
第7题:
class TestMain { static int x = 2; static { x = 4; } static public void main(String[] args) { int y = x + 1; System.out.println(y); } } 和命令行: java TestMain 结果为:()
第8题:
1. interface TestA { String toString(); } 2. public class Test { 3. public static void main(String[] args) { 4. System.out.println(new TestA() { 5. public String toString() { return “test”; } 6. } 7. } 8. } What is the result?()
第9题:
-1
255
127
Compilation will fail.
Compilation will succeed but the program will throw an exception at line 4.
第10题:
The value “4” is printed at the command line.
Compilation fails because of an error in line 5.
Compilation fails because of an error in line 9.
A NullPointerException occurs at runtime.
A NumberFormatException occurs at runtime.
An IllegalStateException occurs at runtime.
第11题:
Value = 3
Value = 4
Value = 5
Value = 6
Value = 7
Value = 8
第12题:
Class A
Compilation fails.
An exception is thrown at line 2.
An exception is thrown at line 6.
The code executes with no output.
第13题:
编译运行下程序后,关于输出结果的说法正确的是( )。 public class conditional{ public smile void main(string args[]){ int x=4; System.out.println("alue is "+((x>4)?99:9)); } }
A.输出结果为 value is 99.99
B.输出结果为 value is 9
C.输出结果为 valueis9.0
D.编译错误
第14题:
编译和运行以下代码结果为:
1. public class EqualsTest{
2. public static void main(String args[]){
3. byte A=(byte)4096;
4. if(A== 4096、System.out.println("Equal");
5. else System.out.println("Not Equal");
6. }
7. }
A.在第3行出现转换丢失精度的编译错误.
B.输出 "Not Equal".
C.输出 "Equal".
第15题:
A. 0
B. 1
C. No Object
D. 编译错误
E. null
第16题:
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?()
第17题:
1. public class A { 2. void A() { 3. System.out.println(“Class A”); 4. } 5. public static void main(String[] args) { 6. new A(); 7. } 8. } What is the result?()
第18题:
现有2 个文件: 1. package x; 2. public class X { 3. public static void doX() { System.out.print("doX "); } 4. } 和: 1. class Find { 2. public static void main(String [] args) { 3. //insert code here 4. } 5. } 哪两行分别插入到类Find 的第3 行将编译并产生输出“doX”? ()
第19题:
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?()
第20题:
doX();
X.doX();
x.X.doX();
x.X myX = new x.X(); myX.doX();
第21题:
Value is: 8
Compilation fails.
Value is: 12
Value is: -12
The code runs with no output.
An exception is thrown at runtime.
第22题:
The program runs and prints “0”
The program runs and prints “1”
The program runs but aborts with an exception.
An error “possible undefined variable” at line 4 causes compilation to fail.
An error “possible undefined variable” at line 9 causes compilation to fail.
第23题:
0
3
4
5
The code will not compile.