5
6
7
12
13
第1题:
Which declarations will allow a class to be started as a standalone program?()
第2题:
What will be the result of attempting to compile and run the following code?() public class Q6b0c { public static void main(String args[]) { int i = 4; float f = 4.3; double d = 1.8; int c = 0; if (i == f) c++; if (((int) (f + d)) == ((int) f + (int) d)) c += 2; System.out.println(c); } }
第3题:
What will be written to the standard output when the following program is run?() public class Q8499 { public static void main(String args[]) { double d = -2.9; int i = (int) d; i *= (int) Math.ceil(d); i *= (int) Math.abs(d); System.out.println(i); } }
第4题:
What will be written to the standard output when the following program is run?() class Base { int i; Base() { add(1); } void add(int v) { i += v; } void print() { System.out.println(i); } } class Extension extends Base { Extension() { add(2); } void add(int v) { i += v*2; } } public class Qd073 { public static void main(String args[]) { bogo(new Extension()); } static void bogo(Base b) { b.add(8); b.print(); } }
第5题:
Public class test ( Public static void stringReplace (String text) ( Text = text.replace (‘j’ , ‘i’); ) public static void bufferReplace (StringBuffer text) ( text = text.append (“C”) ) public static void main (String args[]} ( String textString = new String (“java”); StringBuffer text BufferString = new StringBuffer (“java”); stringReplace (textString); bufferReplace (textBuffer); System.out.printLn (textString + textBuffer); ) ) What is the output?()
第6题:
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 (straing args) ( sub sub = new sub (“Hello”); system.out. PrintIn(sub.i); ) ) What is the result?()
第7题:
public void main(String args[])
public void static main(String args[])
public static main(String[] argv)
final public static void main(String [] array)
public static void main(String args[])
第8题:
The program will terminate with an ArrayIndexOutOfBoundsException.
The program will terminate with a NullPointerException.
4 will be written to standard output.
6 will be written to standard output.
7 will be written to standard output.
第9题:
public static void main(String[] args){}
public static void main(String args){}
public void main(String[] args){}
public static int main(String[] args){}
第10题:
est
es
str
st
s
第11题:
9
18
20
21
22
第12题:
5
6
7
12
13
第13题:
Public class test ( Public static void main (String args[]) ( System.out.printIn (6 ^ 3); ) ) What is the output?()
第14题:
What will be written to the standard output when the following program is run?() public class Qd803 { public static void main(String args[]) { String word = "restructure"; System.out.println(word.substring(2, 3)); } }
第15题:
What will be written to the standard output when the following program is run?() public class Q03e4 { public static void main(String args[]) { String space = " "; String composite = space + "hello" + space + space; composite.concat("world"); String trimmed = composite.trim(); System.out.println(trimmed.length()); } }
第16题:
public class X { public static void main (String[]args) { string s = new string (“Hello”); modify(s); System.out.printIn(s); } public static void modify (String s) { s += “world!”; } } What is the result?()
第17题:
public class X { public static void main (Stringargs) { string s = new string (“Hello”); modify(s); System.out.printIn(s); } public static void modify (String s) { s += “world!”; } } What is the result?()
第18题:
第19题:
The program runs and prints “Hello”
An error causes compilation to fail.
The program runs and prints “Hello world!”
The program runs but aborts with an exception.
第20题:
The program runs and prints “Hello”
An error causes compilation to fail.
The program runs and prints “Hello world!”
The program runs but aborts with an exception.
第21题:
12
18
8
9
27
第22题:
第23题:
81
7
11
0
false
第24题:
The program prints “lava”
The program prints “java”
An error at line 7 causes compilation to fail.
Compilation succeeds but the program throws an exception.