CMS专题

单选题现有:  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())  ;  

题目
单选题
现有:  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 elm tree

D

 tree elm tree elm

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

第1题:

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.elmelmelmelm

B.treeelmelmelm

C.treeelmtreeelm

D.编译失败


参考答案:D

第2题:

下面程序段的输出结果为 public class Test { public static void main(String args[]) { boolean a,b,c; a=(3<5); 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=false

B.a=true b=false b=true c=true

C.a=true b=true b=tree c=false

D.a=false b=false b=tree c=false


正确答案:C
解析:本题考查关系运算符<和=。题目中a=(3<5);比较3和5的大小,因为3<5,返回true给a:b=(a==true);判断a是否为真,因为a确实为真,返回true给b;c =(b==false);判断b是否为假,因为b不为假,返回false给c。最后结果a=true,b=tree, b==true,c=false,选项C正确。

第3题:

●Traversing a binary tree in preorder is equivalent to (68) .

(68) A.Traversing the forest corresponding to the binary tree in root-first order

B.Traversing the forest corresponding to the binary tree in root-last order

C.Traversing the forest corresponding to the binary tree in breadth-first order

D.None of the above


正确答案:A
【解析】前序遍历一个二叉树等价于按从树的根部、右子树、右子树查找顺序查找树。

第4题:

Which command enables RSTP on a switch?()

A. spanning-tree mode rapid-pvst

B. spanning-tree uplinkfast

C. spanning-tree backbonefast

D. spanning-tree mode mst


参考答案:A

第5题:

考虑如下代码:

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" );

else

System.out.println( "Oops" );

}

}

则输出结果中有哪些?

A.Pine B.Tree C.Forest D.Oops E.无输出


正确答案:ABD

第6题:

现有:

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

结果为:()


参考答案:C

第7题:

Traversing a binary tree in preorder is equivalent to(68).

A.Traversing the forest corresponding to the binary tree in root-first order

B.Traversing the forest corresponding to the binary tree in root-last order

C.Traversing the forest corresponding to the binary tree in breadth-first order

D.None of the above


正确答案:A
解析:前序遍历一个二叉树等价于按从树的根部、右子树、右子树查找顺序查找树。

第8题:

It is believed that the tradition of having a pine tree as a Christmas Tree comes from Germany.()


参考答案:正确

第9题:

Which command enhances the 802.1D convergence time on ports that are connected to hosts?()

A. spanning-tree backbonefast

B. spanning-tree uplinkfast

C. spanning-tree portfast

D. spanning-tree cost512


参考答案:C

第10题:

The cottonwood tree Mr. Flanagan found was an extremely tall tree with broad leaves.


正确答案:

更多相关问题