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

题目内容 (请给出正确答案)
单选题
class BitStuff {   BitStuff go() { System.out.print("bits "); return this; }   }   class MoreBits extends BitStuff {   MoreBits go() { System.out.print("more "); return this; }   public static void main(String [] args) {   BitStuff [] bs = {new BitStuff(), new MoreBits()};   for( BitStuff b : bs)   b.go();   }   }   结果为:()
A

bits bits

B

bits more

C

more more

D

编译失败


参考答案

参考解析
解析: 暂无解析
更多 “单选题class BitStuff {   BitStuff go() { System.out.print("bits "); return this; }   }   class MoreBits extends BitStuff {   MoreBits go() { System.out.print("more "); return this; }   public static void main(String [] args) {   BitStuff [] bs = {new BitStuff(), new MoreBits()};   for( BitStuff b : bs)   b.go();   }   }   结果为:()A bits bitsB bits moreC more moreD 编译失败” 相关考题
考题 classBitStuff{BitStuffgo(){System.out.print(bits);returnthis;}}classMoreBitsextendsBitStuff{MoreBitsgo(){System.out.print(more);returnthis;}publicstaticvoidmain(String[]args){BitStuff[]bs={newBitStuff(),newMoreBits()};for(BitStuffb:bs)b.go();}}结果为:()A.bitsbitsB.bitsmoreC.moremoreD.编译失败

考题 class BitStuff {   BitStuff go() { System.out.print("bits "); return this; }   }   class MoreBits extends BitStuff {   MoreBits go() { System.out.print("more "); return this; }   public static void main(String [] args) {   BitStuff [] bs = {new BitStuff(), new MoreBits()};   for( BitStuff b : bs)   b.go();   }   }   结果为:()  A、bits bitsB、bits moreC、more moreD、编译失败

考题 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

考题 现有:  class Parser (类)extends(继承) Utils {   public static void main(String [] args) {   System.out.print(输出打印)(new Parser().getInt("42"));  }   int getInt(String arg) {   return Integer.parseInt(arg);    }   }   class Utils {   int getInt(String arg) throws Exception { return 42; }  }   结果为:()  A、 42B、 编译失败。C、 无输出结果。D、 运行时异常被抛出。

考题 现有  class Parser extends Utils {  public static void main (String  []  args)  {  try  {  System.out.print (new Parser () .getlnt ("42"))       }  catch (Exception e) {  System.out.println ("Exc") ;  }      }  int getlnt (String arg)  throws Exception  {     return Integer.parselnt (arg) ;      }      }  class Utils {  int getlnt ()  {  return 42;  }     }  结果是什么?()      A、 42ExcB、 ExcC、 42D、编译失败

考题 class Flibitz {   public static void main(String [] args) {   int grop = 7;   new Flibitz().go(grop);   System.out.print(grop);   }   void go(int grop) {   if(++grop 〉 7) grop++;   System.out.print(grop);   }   }   结果为:()  A、77B、79C、97D、99

考题 class Guy{String greet(){return “hi“}}   class Cowboy extends Guy {String greet(){return“howdy”}}   class Surfer extends Guy {String greet(){return“dudel”}}  class Greetings{   public static void main (string[]args){   Guy[] guy= {new Guy(),new Cowboy(),new Surfer()};   for(Guy 0: guys)   System.out.print(g.green());  }   }   结果为:  A、运行时异常被输出B、第7行出现一个错误,编译失败C、第8行出现一个错误,编译失败D、hi hi hiE、hi hawdy doude

考题 class Bird {  static void talk() { System.out.print("chirp "); }  }  class Parrot extends Bird {  static void talk() { System.out.print("hello "); }  public static void main(String [] args) {  Bird [] birds = {new Bird(), new Parrot()};  for( Bird b : birds)  b.talk();  }  }  结果为:() A、chirp chirpB、chirp helloC、hello helloD、编译失败

考题 现有:  class Guy {String greet()    {return "hi";  }  }  class Cowboy extends Guy  (  String greet()    (  return "howdy  ¨;    )  )  class Surfer extends Guy  (String greet()    (return "dude! ";)) class Greetings  {  public static void main (String  []  args)    {  Guy  []  guys =  ( new Guy(), new Cowboy(), new Surfer()  );  for (Guy g:  guys) System.out.print (g.greet()};  }  }  结果为:() A、 hi howdy dude!B、运行时异常被抛出。C、第7行出现一个错误,编译失败。D、第8行出现一个错误,编译失败。

考题 final class Tree {  private static String tree = "tree ";  String getTree() { return tree; }  }  class Elm extends Tree {  private static String tree = "elm "; public static void main(String [] args) {  new Elm().go(new Tree());  }  void go(Tree t) {  String s = t.getTree()+Elm.tree+tree+(new Elm().getTree());  System.out.println(s);  } }  结果为:() A、elm elm elm elmB、tree elm elm elmC、tree elm tree elmD、编译失败

考题 class Parser extends Utils {  public static void main (String [] args) {  try { System.out.print(new Parser().getInt("42"));  } catch (NumberFormatException n) {  System.out.println("NFExc "); }  }  int getInt(String arg) throws NumberFormatException {  return Integer.parseInt(arg);  }  }  class Utils {  int getInt(String arg) { return 42; }  }  结果为:() A、42B、NFExcC、42NFExcD、编译失败

考题 class Passer {  static final int x = 5;  public static void main(String [] args) { new Passer().go(x);  System.out.print(x);  }  void go(int x) {  System.out.print(++x);  }  }  结果是什么?() A、55B、56C、65D、66

考题 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 output.E、 An exception is thrown at runtime.

考题 class Parser extends Utils {  public static void main(String [] args) {   System.out.print(new Parser().getInt("42"));  }  int getInt(String arg) {  return Integer.parseInt(arg);  }  }  class Utils {  int getInt(String arg) throws Exception { return 42; }  }  结果为:() A、42B、编译失败C、无输出结果D、运行时异常被抛出

考题 单选题现有:   class Parser extends Utils {   public static void main(String [] args) {     System.out.print(new Parser().getInt("42"));    }   int getInt(String arg) {  return Integer.parseInt(arg);  }    }   class Utils {     int getInt(String arg) throws Exception { return 42; }    }    结果为()A  42B  编译失败。C  无输出结果。D  运行时异常被抛出。

考题 单选题现有:  class Parser extends Utils  { public static void main (String[]  args)    {     try{System.out.print (new Parser().getlnt("42"));      } catch (Exception e)    {      System.out.println("Exc");  }      }  int getlnt (String arg) throws Exception  {      return Integer.parselnt (arg);      }       class Utils  {  int getlnt (String arg)    {return 42;  }      }      结果为()A  42B  ExcC  42ExcD 编译失败

考题 单选题final class Tree {  private static String tree = "tree ";  String getTree() { return tree; }  }  class Elm extends Tree {  private static String tree = "elm "; public static void main(String [] args) {  new Elm().go(new Tree());  }  void go(Tree t) {  String s = t.getTree()+Elm.tree+tree+(new Elm().getTree());  System.out.println(s);  } }  结果为:()A elm elm elm elmB tree elm elm elmC tree elm tree elmD 编译失败

考题 单选题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 output.E  An exception is thrown at runtime.

考题 单选题现有:  class Tree {  private static String tree = "tree ";  String getTree ()  {  return tree;  }       }  class Elm extends Tree {  private static String tree = "elm ";  public static void main (String  []  args)  {       new Elm() .go (new Tree())  ;      } }  void go (Tree t)  {  String  s =  t.getTree () +Elm.tree  +  tree  +   (new  Elm() .getTree ()) ;      System.out.println (s) ;}     结果为:()A  elm elm elm elmB  tree elm elm elmC  tree elm elm treeD  tree elm tree elm

考题 单选题class Bird {  static void talk() { System.out.print("chirp "); }  }  class Parrot extends Bird {  static void talk() { System.out.print("hello "); }  public static void main(String [] args) {  Bird [] birds = {new Bird(), new Parrot()};  for( Bird b : birds)  b.talk();  }  }  结果为:()A chirp chirpB chirp helloC hello helloD 编译失败

考题 单选题class Flibitz {   public static void main(String [] args) {   int grop = 7;   new Flibitz().go(grop);   System.out.print(grop);   }   void go(int grop) {   if(++grop 〉 7) grop++;   System.out.print(grop);   }   }   结果为:()A 77B 79C 97D 99

考题 单选题下列程序的运行结果是(  )。class Shape{ public Shape(){ System.out.print("Shape"); }}class Circle extends Shape{ public Circle(){ System.out.print("Circle"); }}public class Test{ public static void main(String[]args){ Shape d=new Circle(); }}A ShapeB CircleC ShapeCircleD 程序有错误

考题 单选题class Passer {  static final int x = 5;  public static void main(String [] args) { new Passer().go(x);  System.out.print(x);  }  void go(int x) {  System.out.print(++x);  }  }  结果是什么?()A 55B 56C 65D 66

考题 单选题现有:  class Guy {String greet()    {return "hi";  }  }  class Cowboy extends Guy  (  String greet()    (  return "howdy  ¨;    )  )  class Surfer extends Guy  (String greet()    (return "dude! ";)) class Greetings  {  public static void main (String  []  args)    {  Guy  []  guys =  ( new Guy(), new Cowboy(), new Surfer()  );  for (Guy g:  guys) System.out.print (g.greet()};  }  }  结果为:()A  hi howdy dude!B 运行时异常被抛出。C 第7行出现一个错误,编译失败。D 第8行出现一个错误,编译失败。

考题 单选题现有  class Parser extends Utils {  public static void main (String  []  args)  {  try  {  System.out.print (new Parser () .getlnt ("42"))       }  catch (Exception e) {  System.out.println ("Exc") ;  }      }  int getlnt (String arg)  throws Exception  {     return Integer.parselnt (arg) ;      }      }  class Utils {  int getlnt ()  {  return 42;  }     }  结果是什么?()A  42ExcB  ExcC  42D 编译失败

考题 单选题class BitStuff {   BitStuff go() { System.out.print("bits "); return this; }   }   class MoreBits extends BitStuff {   MoreBits go() { System.out.print("more "); return this; }   public static void main(String [] args) {   BitStuff [] bs = {new BitStuff(), new MoreBits()};   for( BitStuff b : bs)   b.go();   }   }   结果为:()A bits bitsB bits moreC more moreD 编译失败

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

考题 单选题class Guy { String greet() { return "hi "; } }  class Cowboy extends Guy { String greet() { return "howdy "; } }  class Wrangler extends Cowboy { String greet() { return "ouch! "; } }  class Greetings2 {  public static void main(String [] args) {  Guy g = new Wrangler();  Guy g2 = new Cowboy();  Wrangler w2 = new Wrangler();  System.out.print(g.greet()+g2.greet()+w2.greet());  }  }  结果是什么?()A hi hi ouch!B hi howdy ouch!C ouch! howdy ouch!D 编译失败