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

题目内容 (请给出正确答案)

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 elm
  • B、tree elm elm elm
  • C、tree elm tree elm
  • D、编译失败

参考答案

更多 “ 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、编译失败” 相关考题
考题 finalclassTree{privatestaticStringtree=tree;StringgetTree(){returntree;}}classElmextendsTree{privatestaticStringtree=elm;publicstaticvoidmain(String[]args){newElm().go(newTree());}voidgo(Treet){Strings=t.getTree()+Elm.tree+tree+(newElm().getTree());System.out.println(s);}}结果为:()A.elmelmelmelmB.treeelmelmelmC.treeelmtreeelmD.编译失败

考题 现有:classTree{privatestaticStringtree=tree;StringgetTree(){returntree;}}classElmextendsTree{privatestaticStringtree=elm;publicstaticvoidmain(String[]args){newElm().go(newTree());}}voidgo(Treet){Strings=t.getTree()+Elm.tree+tree+(newElm().getTree());System.out.println(s);}结果为:()

考题 下面程序的运行结果是( )。 public class OperatorsAndExpressions{ void equalsMethod1( ){ //基本类型的数据之间的比较 int i=10,j=15; System.out,println(i==j); //复合数据类型的数据之间的比较 String s1=new String ("how are you"); String s2=new String ("how are you"); System.out.println(s1==s2): } public static void main (String args[ ]){ OperatorsAndExpressions OperAndExp=new OperatorsAndExpressions( ): //用于基本类型数据和复合类型数据的=="运算符 OperAndExp,equalsMethod1( ) } }A.false falseB.false trueC.tree falseD.true true

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

考题 下面程序段的输出结果为 public class Test { public static void main(String args[]) { boolean a,b,c; a=(35); b=(a==true); System.out.println(”a=”+a+”b=+b) ; c=(b==false); System.out.printhln(”b=”+b+”c=”+c) ; } }A.a=true b=false b=true c=falseB.a=true b=false b=true c=trueC.a=true b=true b=tree c=falseD.a=false b=false b=tree c=false

考题 考虑如下代码:class Tree{}class Pine extends Tree{}class Oak extends Tree{}public class Forest {public static void main( String[] args ) {Tree tree = new Pine();if( tree instanceof Pine )System.out.println( "Pine" );if( tree instanceof Tree )System.out.println( "Tree" );if( tree instanceof Oak )System.out.println( "Oak" );elseSystem.out.println( "Oops" );}}则输出结果中有哪些?A.Pine B.Tree C.Forest D.Oops E.无输出

考题 现有:  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

考题 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[])

考题 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 Mineral {   static String shiny() { return "1"; }   }   class Granite extends Mineral {   public static void main(String [] args) {   String s = shiny() + getShiny();   s = s + super.shiny();   System.out.println(s);   }   static String getShiny() { return shiny(); }   }   结果为:()  A、3B、12C、111D、编译失败

考题 public class Item {  private String desc;  public String getDescription() { return desc; }  public void setDescription(String d) { desc = d; } public static void modifyDesc(Item item, String desc) {  item = new Item();  item.setDescription(desc);  }  public static void main(String[] args) {  Item it = new Item();  it.setDescription(”Gobstopper”);  Item it2 = new Item();  it2.setDescription(”Fizzylifting”);  modifyDesc(it, “Scrumdiddlyumptious”);  System.out.println(it.getDescription());  System.out.println(it2.getDescription());  }  }  What is the outcome of the code? ()A、 Compilation fails.B、 Gobstopper  FizzyliftingC、 Gobstopper  ScrumdiddlyumptiousD、 Scrumdiddlyumptious FizzylifltngE、 Scrumdiddlyumptious Scrumdiddlyumptious

考题 下面哪些选项是正确的main方法说明?()A、 public main(String args[])B、 public static void main(String args[])C、 private static void main(String args[])D、 void main()

考题 声明Java独立应用程序main()方法时,正确表达是()。A、public static void main(String[]args){…}B、private static void main(String args[]){…}C、public void main(String args[]){…}D、public static void main(){…}

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

考题 Public class test (  Public static void stringReplace (String text)  (  Text = text.replace (‘j’ , ‘i’);  )  public static void bufferReplace (StringBuffer text)  (  text = text.append (“C”)  )   public static void main (String args[]}  (  String textString = new String (“java”); StringBuffer text BufferString = new StringBuffer (“java”);  stringReplace (textString);  bufferReplace (textBuffer);  System.out.printLn (textString + textBuffer);  ) )  What is the output?()

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

考题 import java.io.*;  public class Forest implements Serializable {  private Tree tree = new Tree();  public static void main(String [] args) {  Forest f= new Forest();  try {  FileOutputStream fs = new FileOutputStream(”Forest.ser”);  ObjectOutputStream os = new ObjectOutputStream(fs);  os.writeObject(f); os.close();  } catch (Exception ex) { ex.printStackTrace(); }  }  }  class Tree { }  What is the result?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 An instance of Forest is serialized.D、 A instance of Forest and an instance of Tree are both serialized.

考题 单选题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 编译失败

考题 填空题Public class test (  Public static void stringReplace (String text)  (  Text = text.replace (‘j’ , ‘i’);  )  public static void bufferReplace (StringBuffer text)  (  text = text.append (“C”)  )   public static void main (String args[]}  (  String textString = new String (“java”);  StringBuffer text BufferString = new StringBuffer (“java”);  stringReplace (textString);  BufferReplace (textBuffer);  System.out.printLn (textString + textBuffer);  )  )   What is the output?()

考题 多选题Which declarations will allow a class to be started as a standalone program?()Apublic void main(String args[])Bpublic void static main(String args[])Cpublic static main(String[] argv)Dfinal public static void main(String [] array)Epublic static void main(String args[])

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

考题 单选题import java.io.*;  public class Forest implements Serializable {  private Tree tree = new Tree();  public static void main(String [] args) {  Forest f= new Forest();  try {  FileOutputStream fs = new FileOutputStream(”Forest.ser”);  ObjectOutputStream os = new ObjectOutputStream(fs);  os.writeObject(f); os.close();  } catch (Exception ex) { ex.printStackTrace(); }  }  }  class Tree { }  What is the result?()A  Compilation fails.B  An exception is thrown at runtime.C  An instance of Forest is serialized.D  A instance of Forest and an instance of Tree are both serialized.

考题 单选题现有:  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 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 Mineral {   static String shiny() { return "1"; }   }   class Granite extends Mineral {   public static void main(String [] args) {   String s = shiny() + getShiny();   s = s + super.shiny();   System.out.println(s);   }   static String getShiny() { return shiny(); }   }   结果为:()A 3B 12C 111D 编译失败

考题 单选题下面哪些选项是正确的main方法说明?()A  public main(String args[])B  public static void main(String args[])C  private static void main(String args[])D  void main()