Import java.io.*;
Include java.io.*;
Import java.io.PrintWriter;
Include java.io.PrintWriter;
No statement is needed.
第1题:
//point X public class foo { public static void main (String[]args) throws Exception { java.io.printWriter out = new java.io.PrintWriter { new java.io.outputStreamWriter (System.out), true; out.printIn(“Hello”); } } } Which statement at PointX on line 1 allows this code to compile and run?()
第2题:
public class X { public static void main (Stringargs) { String s1 = new String (“true”); Boolean b1 = new Boolean (true); if (s2.equals(b1)) { System.out.printIn(“Equal”); } } } What is the result? ()
第3题:
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?()
第4题:
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?()
第5题:
static void test() throws Error { if (true) throw new AssertionError(); System.out.print(”test “); } public static void main(String[] args) { try { test(); } catch (Exception ex) { System.out.print(”exception “); } System.out.print(”elld “); } What is the result?()
第6题:
public class Threads4 { public static void main (String[] args) { new Threads4().go(); } public void go() { Runnable r = new Runnable() { public void run() { System.out.print(”foo”); } }; Thread t = new Thread(r); t.start(); t.start(); } } What is the result?()
第7题:
The program runs and prints nothing.
The program runs and prints “Equal”
An error at line 5 causes compilation to fail.
The program runs but aborts with an exception.
第8题:
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.
第9题:
4
5
8
9
Compilation fails.
An exception is thrown at runtime.
It is impossible to determine for certain.
第10题:
end
Compilation fails.
exception end
exception test end
A Throwable is thrown by main.
An Exception is thrown by main.
第11题:
Import java.io.PrintWriter;
Include java.io.PrintWriter;
Import java.io.OutputStreamWriter;
Include java.io.OutputStreamWriter;
No statement is needed.
第12题:
finally
exception finished
finally exception finished
Compilation fails.
第13题:
//point X public class foo { public static void main (Stringargs) throws Exception { java.io.printWriter out = new java.io.PrintWriter { new java.io.outputStreamWriter (System.out), true; out.printIn(“Hello”); } } } Which statement at PointX on line 1 allows this code to compile and run?()
第14题:
public class enclosingone ( public class insideone{} ) public class inertest( public static void main (stringargs)( enclosingone eo= new enclosingone (); //insert code here ) ) Which statement at line 7 constructs an instance of the inner class?()
第15题:
//point X public class foo ( public static void main (Stringargs) throws Exception { printWriter out = new PrintWriter (new ) java.io.outputStreamWriter (System.out), true; out.printIn(“Hello”); } ) Which statement at PointX on line 1 allows this code to compile and run?()
第16题:
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?()
第17题:
// Point X public class foo { public static void main(String[] args) throws Exception { jave.io.PrintWriter out = new jave.io.PrintWriter( new jave.io.OutputStreamWriter(System.out), true); out.println(“Hello”); } } Which statement at Point X on line 1 is required to allow this code to compile?()
第18题:
No statement is required.
import jave.io.*;
include java.io.*;
import jave.io.PrintWriter;
include java.io.PrintWriter;
第19题:
InsideOnew ei= eo.new InsideOn();
Eo.InsideOne ei = eo.new InsideOne();
InsideOne ei = EnclosingOne.new InsideOne();
EnclosingOne.InsideOne ei = eo.new InsideOne();
第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题:
Import java.io.PrintWriter;
Include java.io.PrintWriter;
Import java.io.OutputStreamWriter;
Include java.io.OutputStreamWriter;
No statement is needed.
第22题:
Import java.io.*;
Include java.io.*;
Import java.io.PrintWriter;
Include java.io.PrintWriter;
No statement is needed.
第23题:
Import java.io.*;
Include java.io.*;
Import java.io.PrintWriter;
Include java.io.PrintWriter;
No statement is needed.
第24题:
foofoofoofoofoo
foobarfoobarbar
foobarfoofoofoo
foobarfoobarfoo
barbarbarbarbar
foofoofoobarbar
foofoofoobarfoo