网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
单选题
public class Holt extends Thread{    private String sThreadName;  public static void main(String argv[]){         Holt h = new Holt();           h.go();       }  Holt(){}  Holt(String s){  sThreadName = s;    }  public String getThreadName(){        return sThreadName;    }  public void go(){  Holt first = new Holt("first");       first.start();  Holt second = new Holt("second");        second.start();    }  public void start(){  for(int i = 0; i < 2; i ++){  System.out.println(getThreadName() +i);            try{   Thread.sleep(100);                }   catch(InterruptedException e){  System.out.println(e.getMessage());              }            }         } }  当编译运行上面的Java代码时,将会出现()。
A

编译时错误

B

输出first0, second0, first0, second1

C

输出first0, first1, second0, second1

D

运行时错误


参考答案

参考解析
解析: 暂无解析
更多 “单选题public class Holt extends Thread{    private String sThreadName;  public static void main(String argv[]){         Holt h = new Holt();           h.go();       }  Holt(){}  Holt(String s){  sThreadName = s;    }  public String getThreadName(){        return sThreadName;    }  public void go(){  Holt first = new Holt("first");       first.start();  Holt second = new Holt("second");        second.start();    }  public void start(){  for(int i = 0; i  2; i ++){  System.out.println(getThreadName() +i);            try{   Thread.sleep(100);                }   catch(InterruptedException e){  System.out.println(e.getMessage());              }            }         } }  当编译运行上面的Java代码时,将会出现()。A 编译时错误B 输出first0, second0, first0, second1C 输出first0, first1, second0, second1D 运行时错误” 相关考题
考题 阅读下面程序 public class Test2 ______ { public static void main(String[] args) { Thread t=new Test2(); t.start(); } public void run() { System.out.println("How are you."); } } 程序中下画线处应填入的正确选项是A.implements ThreadB.extends RunnableC.implements RunnableD.extends Thread

考题 class MyThread extends Thread {  public void run() { System.out.println(“AAA”); }  public void run(Runnable r) { System.out.println(“BBB”); }  public static void main(String[] args) {  new Thread(new MyThread()).start();  }  }   What is the result?()  A、 AAAB、 BBBC、 Compilation fails.D、 The code runs with no output.

考题 public class Pet{     private String name;     public Pet(){  System.out.print(1);    }  public Pet(String name){        System.out.print(2);    } }  public class Dog extends Pet{     public Dog(String name){        System.out.print(3);    } }  执行new Dog(“棕熊”);后程序输出是哪项?() A、 23B、 13C、 123D、 321

考题 Which statements concerning the following code are true?()   class a {   public a() {}   public a(int i) { this(); }   }   class b extends a {   public boolean b(String msg) { return false; }   }   class c extends b  {  private c() { super(); }   public c(String msg) { this(); }   public c(int i) {}   }  A、The code will fail to compile.B、The constructor in a that takes an int as an argument will never be called as a result of constructing an  object of class b or c.C、Class c has three constructors.D、Objects of class b cannot be constructed.E、At most one of the constructors of each class is called as a result of constructing an object of class c.

考题 Which three demonstrate an “is a” relationship?() A、 public class X { }  public class Y extends X { }B、 public interface Shape { }  public interface Rectangle extends Shape{ }C、 public interface Color { }  public class Shape { private Color color; }D、 public interface Species { }  public class Animal { private Species species; }E、 public class Person { } public class Employee {  public Employee(Person person) { }F、 interface Component { }  class Container implements Component { private Component[] children; }

考题 public class Employee{       private String name;  public Employee(String name){           this.name = name;      }  public String getName(){         return name;      } }  public class Manager extends Employee{       public Manager(String name){          System.out.println(getName());      } }  执行语句new Manager(“smith”)后程序的输出是哪项?() A、 smithB、 nullC、 编译错误D、 name

考题 public class A extends Thread {  A() {  setDaemon(true);  }  public void run() {  (new B()).start();  try {  Thread.sleep(60000);  } catch (InterruptedException x) {}  System.out.println(“A done”);  }  class B extends Thread {  public void run() {  try {  Thread.sleep(60000);  } catch (InterruptedException x) {}  System.out.println(“B done”);  }  }  public static void main(String[] args) {  (new A()).start();  }  }   What is the result?()  A、 A doneB、 B doneC、 A done B doneD、 B done A doneE、 There is no exception that the application will print anything.F、 The application outputs “A done” and “B done”, in no guaranteed order.

考题 public class Holt extends Thread{    private String sThreadName;  public static void main(String argv[]){         Holt h = new Holt();           h.go();       }  Holt(){}  Holt(String s){  sThreadName = s;    }  public String getThreadName(){        return sThreadName;    }  public void go(){  Holt first = new Holt("first");       first.start();  Holt second = new Holt("second");        second.start();    }  public void start(){  for(int i = 0; i  2; i ++){  System.out.println(getThreadName() +i);            try{   Thread.sleep(100);                }   catch(InterruptedException e){  System.out.println(e.getMessage());              }            }         } }  当编译运行上面的Java代码时,将会出现()。 A、编译时错误B、输出first0, second0, first0, second1C、输出first0, first1, second0, second1D、运行时错误

考题 public class Employee{   private String name;   public Employee(String name){   this.name = name;  }   public void display(){   System.out.print(name);  }  }   public class Manager extends Employee{   private String department;   public Manager(String name,String department){   super(name);   this.department = department;  }   public void display(){   System.out.println( super.display()+”,”+department);  }   }   执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?() A、 smith,SALESB、 null,SALESC、 smith,nullD、 null,null

考题 Public class Holt extends Thread{   Private String sThreadName;   Public static void main(String argv[]) {  Holt  h=new Holt(); h.go(); Holt(){};  Holt(String s){ sThreadName=s;  Public String getThreadName() {  return sThreadName;} }  Public void go(){  Hot first=new Hot("first"); first.start();  Hot second=new Hot("second"); second.start();  }  Public void start() {  For(int i=0;i2;i++) {  System.out.print(getThreadName()+i); Try{  Thread.sleep(100); }catch(Exception e){  System.out.print(e.getMessage()) ;  } } }  }  当编译运行上面代码时,将会出现() A、编译时错误B、输出first0,second0,first0,second1C、输出first0,first1,second10,second1D、运行时错误

考题 public class X {  public X aMethod() { return this;}  }  public class Y extends X {  }  Which two methods can be added to the definition of class Y?()A、 public void aMethod() {}B、 private void aMethod() {}C、 public void aMethod(String s) {}D、 private Y aMethod() { return null; }E、 public X aMethod() { return new Y(); }

考题 Which the two demonstrate an “is a” relationship?()A、 public interface Person {}  Public class Employee extends Person {}B、 public interface Shape {}  public interface Rectangle extends Shape {}C、 public interface Color {}  public class Shape { private Color color; }D、 public class Species {}  public class Animal { private Species species; }E、 interface Component {} Class Container implements Component {private Component [] children;

考题 Which two demonstrate an “is a” relationship?()   A、 public interface Person { }  public class Employee extends Person { }B、 public interface Shape { }  public class Employee extends Shape { }C、 public interface Color { }  public class Employee extends Color { }D、 public class Species { }  public class Animal (private Species species;)E、 interface Component { }  Class Container implements Component ( Private Component[ ]children;  )

考题 public class Plant {  private String name;  public Plant(String name) { this.name = name; }  public String getName() { return name; }  }  public class Tree extends Plant {  public void growFruit() { }  public void dropLeaves() { }  }  Which is true?() A、 The code will compile without changes.B、 The code will compile if public Tree() { Plant(); } is added to the Tree class.C、 The code will compile if public Plant() { Tree(); } is added to the Plant class.D、 The code will compile if public Plant() { this(”fern”); } is added to the Plant class.E、 The code will compile if public Plant() { Plant(”fern”); } is added to the Plant class.

考题 Given the following code:     1) class Parent {     2) private String name;     3) public Parent(){}     4) }  5) public class Child extends Parent {     6) private String department;  7) public Child() {}  8) public String getValue(){ return name; }     9) public static void main(String arg[]) {     10) Parent p = new Parent();     11) }  12) }  Which line will cause error?()   A、 line 3B、 line 6C、 line 7D、 line 8E、 line 10

考题 public abstract class Shape {  private int x;  private int y;  public abstract void draw();  public void setAnchor(int x, int y) {  this.x = x;  this.y = y;  }  }  Which two classes use the Shape class correctly?()A、 public class Circle implements Shape { private int radius; }B、 public abstract class Circle extends Shape { private int radius; }C、 public class Circle extends Shape { private int radius; public void draw(); }D、 public abstract class Circle implements Shape { private int radius; public void draw(); }E、 public class Circle extends Shape { private int radius;public void draw() {/* code here */} }F、 public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }

考题 单选题public class Employee{       private String name;  public Employee(String name){           this.name = name;      }  public void display(){         System.out.print(name);      } }  public class Manager extends Employee{       private String department;  public Manager(String name,String department){          super(name);  this.department = department;  }  public void display(){  System.out.println(super.display()+”,”+department);      } }  执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()A  smith,SALESB  null,SALESC  smith,nullD  null,nullE  编译错误

考题 单选题public class Employee{       private String name;  public Employee(String name){           this.name = name;      }  public String getName(){         return name;      } }  public class Manager extends Employee{       private String department;  public Manager(String name,String department){          this.department = department;          super(name);  System.out.println(getName());      }  }  执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()A  smithB  nullC  SALESD  编译错误

考题 多选题Which statements concerning the following code are true?()   class a {   public a() {}   public a(int i) { this(); }   }   class b extends a {   public boolean b(String msg) { return false; }   }   class c extends b  {  private c() { super(); }   public c(String msg) { this(); }   public c(int i) {}   }AThe code will fail to compile.BThe constructor in a that takes an int as an argument will never be called as a result of constructing an  object of class b or c.CClass c has three constructors.DObjects of class b cannot be constructed.EAt most one of the constructors of each class is called as a result of constructing an object of class c.

考题 单选题public class Employee{   private String name;   public Employee(String name){   this.name = name;  }   public String getName(){   return name;  }  }   public class Manager extends Employee{   public Manager(String name){   System.out.println(getName());  }  }   执行语句new Manager(“smith”)后程序的输出是哪项?()A  smithB  nullC  编译错误D  name

考题 多选题Which two demonstrate an “is a” relationship?()Apublic interface Person { }  public class Employee extends Person { }Bpublic interface Shape { }  public class Employee extends Shape { }Cpublic interface Color { }  public class Employee extends Color { }Dpublic class Species { }  public class Animal (private Species species;)Einterface Component { }  Class Container implements Component ( Private Component[ ]children;  )

考题 单选题public class Plant {  private String name;  public Plant(String name) { this.name = name; }  public String getName() { return name; }  }  public class Tree extends Plant {  public void growFruit() { }  public void dropLeaves() { }  }  Which is true?()A  The code will compile without changes.B  The code will compile if public Tree() { Plant(); } is added to the Tree class.C  The code will compile if public Plant() { Tree(); } is added to the Plant class.D  The code will compile if public Plant() { this(”fern”); } is added to the Plant class.E  The code will compile if public Plant() { Plant(”fern”); } is added to the Plant class.

考题 多选题Which the two demonstrate an “is a” relationship?()Apublic interface Person {}  Public class Employee extends Person {}Bpublic interface Shape {}  public interface Rectangle extends Shape {}Cpublic interface Color {}  public class Shape { private Color color; }Dpublic class Species {}  public class Animal { private Species species; }Einterface Component {} Class Container implements Component {private Component [] children;

考题 单选题public class A extends Thread {  A() {  setDaemon(true);  }  public void run() {  (new B()).start();  try {  Thread.sleep(60000);  } catch (InterruptedException x) {}  System.out.println(“A done”);  }  class B extends Thread {  public void run() {  try {  Thread.sleep(60000);  } catch (InterruptedException x) {}  System.out.println(“B done”);  }  }  public static void main(String[] args) {  (new A()).start();  }  }   What is the result?()A  A doneB  B doneC  A done B doneD  B done A doneE  There is no exception that the application will print anything.F  The application outputs “A done” and “B done”, in no guaranteed order.

考题 单选题Given the following code:     1) class Parent {     2) private String name;     3) public Parent(){}     4) }  5) public class Child extends Parent {     6) private String department;  7) public Child() {}  8) public String getValue(){ return name; }     9) public static void main(String arg[]) {     10) Parent p = new Parent();     11) }  12) }  Which line will cause error?()A  line 3B  line 6C  line 7D  line 8E  line 10

考题 单选题public class Employee{   private String name;   public Employee(String name){   this.name = name;  }   public void display(){   System.out.print(name);  }  }   public class Manager extends Employee{   private String department;   public Manager(String name,String department){   super(name);   this.department = department;  }   public void display(){   System.out.println( super.display()+”,”+department);  }   }   执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()A  smith,SALESB  null,SALESC  smith,nullD  null,null

考题 单选题public class Employee{   private String name;   public Employee(String name){   this.name = name;  }   public String getName(){   return name;  }  }   public class Manager extends Employee{   private String department;   public Manager(String name,String department){   this.department = department;   super(name); (应于上一行掉位置)   System.out.println(getName());  }  }   Super的位置是否在方法的首行   执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()A  smithB  nullC  SALESD  编译错误

考题 多选题public class Car {  private int wheelCount;  private String vin;  public Car(String vin) {  this.vin = vin;  this.wheelCount = 4;  }  public String drive() {  return “zoom-zoom”;  }  public String getInfo() {  return “VIN: “+ vin + “wheels: “+ wheelCount;  }  }  And:  public class MeGo extends Car {  public MeGo(String vin) {  this.wheelCount = 3;  }  }  What two must the programmer do to correct the compilation errors?()Ainsert a call to this() in the Car constructorBinsert a call to this() in the MeGo constructorCinsert a call to super() in the MeGo constructorDinsert a call to super(vin) in the MeGo constructorEchange the wheelCount variable in Car to protectedFchange line 3 in the MeGo class to super.wheelCount = 3;