单选题//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?()A Import java.io.PrintWriter;B Include java.io.PrintWriter;C Import java.io.OutputStreamWriter;D Include java.io.OutputStreamWriter;E No statement is needed.

单选题
//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?()
A

 Import java.io.PrintWriter;

B

 Include java.io.PrintWriter;

C

 Import java.io.OutputStreamWriter;

D

 Include java.io.OutputStreamWriter;

E

 No statement is needed.


参考解析

解析: 暂无解析

相关考题:

下面程序的输出结果是什么? class Foo{ static void change(String s){ s=s.replace('j','l'); } public static void main(String args[]){ String s="java"; change(s); System.out.println(s); } }()A.lavaB.javaC.编译错误D.运行时出现异常

public class Something {public static void main(String[] args) {Something s = new Something();System.out.println("s.doSomething() returns " + doSomething());}public String doSomething() {return "Do something ...";}}看上去很完美。

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();}}

以下哪个是Java应用程序main方法的有效定义? A. public static void main();B. public static void main( String args );C. public static void main( String args[] );D. public static void main( Graphics g );E. public static boolean main( String a[] );

public class Test {   public static void main (String args) {  string foo = “blue”;  string bar = foo;   foo = “green”;   System.out.printIn(bar);   }   }   What is the result?()  A、 An exception is thrown.B、 The code will not compile.C、 The program prints “null”D、 The program prints “blue”E、 The program prints “green”

Which declarations will allow a class to be started as a standalone program?()  A、public void main(String args[])B、public void static main(String args[])C、public static main(String[] argv)D、final public static void main(String [] array)E、public static void main(String args[])

public class Base {  public static final String FOO = “foo”;  public static void main(String[] args) {  Base b = new Base();  Sub s = new Sub();  System.out.print(Base.FOO);  System.out.print(Sub.FOO);  System.out.print(b.FOO);  System.out.print(s.FOO);  System.out.print(((Base)s).FOO);  } }  class Sub extends Base {public static final String FOO=bar;}  What is the result?() A、 foofoofoofoofooB、 foobarfoobarbarC、 foobarfoofoofooD、 foobarfoobarfooE、 barbarbarbarbarF、 foofoofoobarbarG、 foofoofoobarfoo

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?() A、 s 14B、 s 16C、 s 10D、 Compilation fails.E、 An exception is thrown at runtime.

下列有关main()方法的签名正确的是哪些?()A、 public static void main(String[] args){}B、 public static void main(){}C、 public static void main(String args[]){}D、 public void static main(String[] args){}

class Foo {  private int x;  publicFoo(intx) {this.x=x; }  public void setX( int x) { this.x = x; }  public int getX() { return x; }  }   public class Gamma {  static Foo fooBar( Foo foo) {  foo = new Foo( 100);  return foo;  }  public static void main( String[] args) {  Foo foo = new Foo( 300);  System.out.print( foo.getX() + “-“);  Foo fooFoo = fooBar( foo);  System.out.print( foo.getX() + “-“);  System.out.print( fooFoo.getX() + “-“);  foo = fooBar( fooFoo);  System.out.print( foo.getX() + “-“);  System.out.prmt( fooFoo.getX());  }  }  What is the output of this program?()A、 300-100-100-100-100B、 300-300-100-100-100C、 300-300-300-100-100D、 300-300-300-300-100

public class Foo {  static int[] a;  static { a[0]=2; }  public static void main( String[] args) {}  }  Which exception or error will be thrown when a programmer attempts to run this code?() A、 java.lang. StackOverflowErrorB、 java.lang.IllegalStateExceptionC、 java.lang.ExceptionlnlnitializerErrorD、 java.lang.ArraylndexOutOfBoundsException

public class Delta {  static boolean foo(char c) {  System.out.print(c);  return true;  }  public static void main( String[] argv ) {  int i =0;  for ( foo(‘A’); foo(‘B’)(i2); foo(‘C’)){  i++ ;  foo(‘D’);  }  }  }  What is the result?()  A、 ABDCBDCBB、 ABCDABCDC、 Compilation fails.D、 An exception is thrown at runtime.

public class Test {  public static void main(String args[]) {  class Foo {  public int i = 3; }  Object o = (Object)new Foo();   Foo foo = (Foo)o;  System.out.println(“i = “ + foo.i); }  }  What is the result?()  A、 i = 3B、 Compilation fails.C、 A ClassCastException is thrown at line 6.D、 A ClassCastException is thrown at line 7.

public class Foo {  public static void main(String[] args) {  try {  return;  } finally {  System.out.println( “Finally” );  }  }  }  What is the result?()A、 FinallyB、 Compilation fails.C、 The code runs with no output.D、 An exception is thrown at runtime.

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?() A、The program runs and prints “Hello”B、An error causes compilation to fail.C、The program runs and prints “Hello world!”D、The program runs but aborts with an exception.

下面哪些main方法可用于程序执行()A、public static void main(String[]args)B、public static void main(String[]x)C、public static void main(Stringargs[])D、public void main(String[]args)

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?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 The code executes normally and prints „foo”.D、 The code executes normally, but nothing is printed.

多选题Which are syntactically valid statement at// point x?()     class Person {     private int a;  public int change(int m){  return m;  }     }  public class Teacher extends Person {     public int b;  public static void main(String arg[]){     Person p = new Person();     Teacher t = new Teacher();    int i;  // point x     }    }Ai = m;Bi = b;Ci = p.a;Di = p.change(30);Ei = t.b.

单选题public class Test {   public static void main (String args) {   class Foo {   public int i = 3;  }   Object o = (Object) new Foo();   Foo foo = (Foo)o;   System.out.printIn(foo. i);  }   }   What is the result?()A Compilation will fail.B Compilation will succeed and the program will print “3”C Compilation will succeed but the program will throw a ClassCastException at line 6.D Compilation will succeed but the program will throw a ClassCastException at line 7.

单选题public class foo {  static String s;  public static void main (String[]args) {  system.out.printIn (“s=” + s);  } }  What is the result?()A The code compiles and “s=” is printed.B The code compiles and “s=null” is printed.C The code does not compile because string s is not initialized.D The code does not compile because string s cannot be referenced.E The code compiles, but a NullPointerException is thrown when toString is called.

单选题public class Test {  public static void main (String [] args)  {  string foo = “blue”;  string bar = foo;  foo = “green”;  System.out.printIn(bar);  }  }   What is the result?()A An exception is thrown.B The code will not compile.C The program prints “null”D The program prints “blue”E The program prints “green”

单选题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?()A s 14B s 16C s 10D Compilation fails.E An exception is thrown at runtime.

单选题public class Test {  public static void main(String args[]) {  class Foo {  public int i = 3; }  Object o = (Object)new Foo();   Foo foo = (Foo)o;  System.out.println(“i = “ + foo.i); }  }  What is the result?()A i = 3B Compilation fails.C A ClassCastException is thrown at line 6.D A ClassCastException is thrown at line 7.

多选题public class Foo {   private int val;   public foo(int v) (val = v;) }   public static void main (String args) {   Foo a = new Foo (10);   Foo b = new Foo (10);   Foo c = a;   int d = 10;   double e = 10.0;   }   Which three logical expression evaluate to true? ()A(a ==c)B(d ==e)C(b ==d)D(a ==b)E(b ==c)F(d ==10.0)

单选题public class Delta {  static boolean foo(char c) {  System.out.print(c);  return true;  }  public static void main( String[] argv ) {  int i =0;  for ( foo(‘A’); foo(‘B’)(i2); foo(‘C’)){  i++ ;  foo(‘D’);  }  }  }  What is the result?()A ABDCBDCBB ABCDABCDC Compilation fails.D An exception is thrown at runtime.

单选题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?()A The program runs and prints “Hello”B An error causes compilation to fail.C The program runs and prints “Hello world!”D The program runs but aborts with an exception.

单选题public class Base {  public static final String FOO = “foo”;  public static void main(String[] args) {  Base b = new Base();  Sub s = new Sub();  System.out.print(Base.FOO);  System.out.print(Sub.FOO);  System.out.print(b.FOO);  System.out.print(s.FOO);  System.out.print(((Base)s).FOO);  } }  class Sub extends Base {public static final String FOO=bar;}  What is the result?()A foofoofoofoofooB foobarfoobarbarC foobarfoofoofooD foobarfoobarfooE barbarbarbarbarF foofoofoobarbarG foofoofoobarfoo

单选题public class Foo {  static int[] a;  static { a[0]=2; }  public static void main( String[] args) {}  }  Which exception or error will be thrown when a programmer attempts to run this code?()A java.lang. StackOverflowErrorB java.lang.IllegalStateExceptionC java.lang.ExceptionlnlnitializerErrorD java.lang.ArraylndexOutOfBoundsException