单选题class Base {  Base() { System.out.print(“Base”); }  }  public class Alpha extends Base {  public static void main( String[] args ) {  new Alpha();  new Base();  }  }  What is the result?()ABaseBBaseBaseCCompilation fails.DThe code runs with no output.E

题目
单选题
class Base {  Base() { System.out.print(“Base”); }  }  public class Alpha extends Base {  public static void main( String[] args ) {  new Alpha();  new Base();  }  }  What is the result?()
A

 Base

B

 BaseBase

C

 Compilation fails.

D

 The code runs with no output.

E

 An exception is thrown at runtime.


相似考题
更多“单选题class Base {  Base() { System.out.print(“Base”); }  }  public class Alpha extends Base {  public static void main( String[] args ) {  new Alpha();  new Base();  }  }  What is the result?()A  BaseB  BaseBaseC  Compilation fails.D  The code runs with no ”相关问题
  • 第1题:

    写出程序运行的结果

    Public class Base

    Public virtual string Hello() {return “Base”;}

    Public class Sub:Base

    Public override string Hello() {return “Sub”;}

    1. Base b = new Base(); b.Hello;

    2. Sub s = new Sub(); s.Hello;

    3. Base b = new Sub (); b.Hello;

    4. Sub s = new Base(); s.Hello;


    正确答案:
     

  • 第2题:

    以下程序的编译和运行结果为?

    abstract class Base{

    abstract public void myfunc();

    public void another(){

    System.out.println("Another method");

    }

    }

    public class Abs extends Base{

    public static void main(String argv[]){

    Abs a = new Abs();

    A.amethod();

    }

    public void myfunc(){

    System.out.println("My Func");

    }

    public void amethod(){

    myfunc();

    }

    }

    A.输出结果为 My Func

    B.编译指示 Base 类中无抽象方法

    C.编译通过,但运行时指示Base 类中无抽象方法

    D.编译指示Base 类中的myfunc方法无方法体,没谁会喜欢该方法。


    正确答案:A

  • 第3题:

    以下程序的调试结果为?class Base{public final void amethod(){System.out.println("amethod");}}public class Fin extends Base{public static void main(String argv[]){Base b = new Base();b.amethod();}}

    A.编译指示带有final 方法的类自己必须定义为final

    B.编译指示不能继承含有final 方法的类

    C.运行错误,原因是Base类没有定义为final类

    D.运行输出 amethod


    正确答案:D

  • 第4题:

    设有如下代码:

    class Base{}

    public class MyCast extends Base{

    static boolean b1=false;

    static int i = -1;

    static double d = 10.1;

    public static void main(String argv[]){

    MyCast m = new MyCast();

    Base b = new Base();

    //Here

    }

    }

    则在 //Here处插入哪个代码将不出现编译和运行错误。

    A.b=m;

    B.m=b;

    C.d =i;

    D.b1 =i;


    正确答案:AC

  • 第5题:

    public class Alpha{  private static Character() ids;  public static void main( String[] args){  ids = new Character[args.length];  for (int i=0; iids[i] = new Character( args[i] );  System.out.print( ids[i] );  }  }  }   What is correct?()  

    • A、 Compilation fails.
    • B、 The code runs with no output.
    • C、 An exception is thrown at runtime.
    • D、 The code runs, outputing a concatenated list of the arguments passed to the program.

    正确答案:A

  • 第6题:

    public class Alpha{  public static void main( string[] args ){  if ( args.length == 2 ) {  if ( args.[0].equalsIgnoreCase(“-b”) )  System.out.println( new Boolean( args[1] ));  }  }  }   And the code is invoked by using the command: java Alpha –b TRUE   What is the result?()  

    • A、 true
    • B、 null
    • C、 false
    • D、 Compilation fails.
    • E、 The code runs with no output.
    • F、 An exception is thrown at runtime.

    正确答案:A

  • 第7题:

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

    • A、9
    • B、18
    • C、20
    • D、21
    • E、22

    正确答案:E

  • 第8题:

    interface Beta {}  class Alpha implements Beta {  String testIt() {  return “Tested”;  }  }  public class Main1 {  static Beta getIt() {  return new Alpha();  }  public static void main( String[] args ) {  Beta b = getIt();  System.out.println( b.testIt() );  }  }  What is the result?()  

    • A、 Tested
    • B、 Compilation fails.
    • C、 The code runs with no output.
    • D、 An exception is thrown at runtime.

    正确答案:B

  • 第9题:

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

     AAA

    B

     BBB

    C

     Compilation fails.

    D

     The code runs with no output.


    正确答案: B
    解析: 暂无解析

  • 第10题:

    单选题
    public class Alpha{  private static Character() ids;  public static void main( String[] args){  ids = new Character[args.length];  for (int i=0; iids[i] = new Character( args[i] );  System.out.print( ids[i] );  }  }  }   What is correct?()
    A

     Compilation fails.

    B

     The code runs with no output.

    C

     An exception is thrown at runtime.

    D

     The code runs, outputing a concatenated list of the arguments passed to the program.


    正确答案: C
    解析: Compilation fails. Line 2: Return Type required.

  • 第11题:

    单选题
    class TestA {  public void start() { System.out.println(”TestA”); }  }  public class TestB extends TestA {  public void start() { System.out.println(”TestB”); } public static void main(String[] args) {  ((TestA)new TestB()).start();  }  }  What is the result?()
    A

     TestA

    B

     TestB

    C

     Compilation fails.

    D

     An exception is thrown at runtime.


    正确答案: C
    解析: 暂无解析

  • 第12题:

    单选题
    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();   }   }
    A

    9

    B

    18

    C

    20

    D

    21

    E

    22


    正确答案: E
    解析: 暂无解析

  • 第13题:

    设有类定义如下:

    class Base{

    public Base(int i){}

    }

    public class MyOver extends Base{

    public static void main(String arg[]){

    MyOver m = new MyOver(10);

    }

    MyOver(int i){

    super(i);

    }

    MyOver(String s, int i){

    this(i);

    //Here

    }

    }

    以下哪条语句可以安排在//Here处 ?

    A.MyOver m = new MyOver();

    B.super();

    C.this("Hello",10);

    D.Base b = new Base(10);


    正确答案:D

  • 第14题:

    以下程序调试结果为:class Base{Base(){int i = 100;System.out.print (i);}}public class Pri extends Base{static int i = 200;public static void main(String argv[]){Pri p = new Pri();System.out.print(i);}}

    A.编译错误

    B.200

    C.100200

    D.100


    正确答案:C

  • 第15题:

    设有如下代码:

    interface IFace{}

    class CFace implements IFace{}

    class Base{}

    public class ObRef extends Base{

    public static void main(String argv[]){

    ObRef bj = new ObRef();

    Base b = new Base();

    Object obj1 = new Object();

    IFace obj2 = new CFace();

    //Here

    }

    }

    则在 //Here处插入哪个代码将不出现编译和运行错误。

    A.obj1=obj2;

    B.b=obj;

    C.obj=b;

    D.obj1=b;


    正确答案:ABD

  • 第16题:

    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、 AAA
    • B、 BBB
    • C、 Compilation fails.
    • D、 The code runs with no output.

    正确答案:A

  • 第17题:

    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

  • 第18题:

    class TestA {  public void start() { System.out.println(”TestA”); }  }  public class TestB extends TestA {  public void start() { System.out.println(”TestB”); } public static void main(String[] args) {  ((TestA)new TestB()).start();  }  }  What is the result?() 

    • A、 TestA
    • B、 TestB
    • C、 Compilation fails.
    • D、 An exception is thrown at runtime.

    正确答案:B

  • 第19题:

    Given the following code, write a line of code that, when inserted at the indicated location, will make the overriding method in Extension invoke the overridden method in class Base on the current object.   class Base {   public void print( ) {   System.out.println("base");   }   }   class Extention extends Base {   public void print( ) {   System.out.println("extension");   // insert line of implementation here   }   }   public class Q294d {   public static void main(String args[]) {   Extention ext = new Extention( );   ext.print( );   }   }   Fill in a single line of implementation.()


    正确答案:super.print();

  • 第20题:

    class Base {  Base() { System.out.print(“Base”); }  }  public class Alpha extends Base {  public static void main( String[] args ) {  new Alpha();  new Base();  }  }  What is the result?()  

    • A、 Base
    • B、 BaseBase
    • C、 Compilation fails.
    • D、 The code runs with no output.
    • E、 An exception is thrown at runtime.

    正确答案:B

  • 第21题:

    单选题
    interface Beta {}  class Alpha implements Beta {  String testIt() {  return “Tested”;  }  }  public class Main1 {  static Beta getIt() {  return new Alpha();  }  public static void main( String[] args ) {  Beta b = getIt();  System.out.println( b.testIt() );  }  }  What is the result?()
    A

     Tested

    B

     Compilation fails.

    C

     The code runs with no output.

    D

     An exception is thrown at runtime.


    正确答案: C
    解析: 暂无解析

  • 第22题:

    单选题
    class Base {  Base() { System.out.print(“Base”); }  }  public class Alpha extends Base {  public static void main( String[] args ) {  new Alpha();  new Base();  }  }  What is the result?()
    A

     Base

    B

     BaseBase

    C

     Compilation fails.

    D

     The code runs with no output.

    E

     An exception is thrown at runtime.


    正确答案: C
    解析: 暂无解析

  • 第23题:

    单选题
    public class Alpha{  public static void main( string[] args ){  if ( args.length == 2 ) {  if ( args.[0].equalsIgnoreCase(“-b”) )  System.out.println( new Boolean( args[1] ));  }  }  }   And the code is invoked by using the command: java Alpha –b TRUE   What is the result?()
    A

     true

    B

     null

    C

     false

    D

     Compilation fails.

    E

     The code runs with no output.

    F

     An exception is thrown at runtime.


    正确答案: B
    解析: 暂无解析

  • 第24题:

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


    正确答案: B
    解析: 暂无解析