单选题// 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

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

 No statement is required.

B

 import jave.io.*;

C

 include java.io.*;

D

 import jave.io.PrintWriter;

E

 include java.io.PrintWriter;

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

下列程序段的输出是( )。 public class Test { public static void main (String args[ ]) { String ss1 = new String("hello"); String ss2 = new String("hello"); System.out.println(ssl == ss2); System.out.println (ssequals(ss2)); } }

A.true, false

B.true, true

C.false, true

D.false, false


第2题:

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、 foofoofoofoofoo
  • B、 foobarfoobarbar
  • C、 foobarfoofoofoo
  • D、 foobarfoobarfoo
  • E、 barbarbarbarbar
  • F、 foofoofoobarbar
  • G、 foofoofoobarfoo

正确答案:D

第3题:

请阅读下面程序 public class ThreadTest { public static void main(String args[]) throws Exception{ int i=0; Hello t=new Hello(); while(true) { System.out.println("Good Moming"+i++); if (i==2 && t.isAlive()) { System. out.println("Main waiting for Hello!"); t.join(); //等待t运行结束 } if(i==5) break;} } } class Hello extends Thread { int i; public void run() { while(true){ System.out.println("Hello"+i++); if (i==5) break;}}} 为使该程序正确执行,下划线处的语句应是

A.t.sleep()

B.t.yield()

C.t.interrupt()

D.t.start()


正确答案:D
解析:本题考查线程的基本知识。程序中通过继承Thread类来创建线程,而Java中新创建的线程不会自动运行,必须调用线程的start()方法,才能运行该线程。因此,下划线处的语句应调用线程的start()方法,即t.start()。
  Thread类还提供了—些方法对线程进行基本控制,其中,join()方法使当前线程暂停执行,等待调用该方法的线程结束后,再恢复执行:isAlive()方法用来测试线程是否活着。
  因此,本题的正确答案是选项D。

第4题:

//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?()  

  • A、 Import java.io.*;
  • B、 Include java.io.*;
  • C、 Import java.io.PrintWriter;
  • D、 Include java.io.PrintWriter;
  • E、 No statement is needed.

正确答案:E

第5题:

Which statements, when inserted at the indicated position in the following code, will cause a runtime exception when attempting to run the program?()   class A {}   class B extends A {}   class C extends A {}   public class Q3ae4 {   public static void main(String args[]) {   A x = new A();   B y = new B();   C z = new C();   // insert statement here   }   } 

  • A、x = y;
  • B、z = x;
  • C、y = (B) x;
  • D、z = (C) y;
  • E、y = (A) y;

正确答案:C

第6题:

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     }    } 

  • A、 i = m;
  • B、 i = b;
  • C、 i = p.a;
  • D、 i = p.change(30);
  • E、 i = t.b.

正确答案:D,E

第7题:

//point X  public class foo (  public static void main (String[]args) 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.

正确答案:A

第8题:

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 来明确。

第9题:

public class Test {  public static void aMethod() throws Exception {  try {  throw new Exception(); } finally {  System.out.println(“finally”);  }  }  public static void main(String args[]) {  try {  aMethod();  } catch (Exception e) {  System.out.println(“exception”);  }  System.out.println(“finished”);  }  }  What is the result?()  

  • A、 finally
  • B、 exception finished
  • C、 finally exception finished
  • D、 Compilation fails.

正确答案:C

第10题:

//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?()  

  • A、 Import java.io.*;
  • B、 Include java.io.*;
  • C、 Import java.io.PrintWriter;
  • D、 Include java.io.PrintWriter;
  • E、 No statement is needed.

正确答案:E

更多相关问题