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

题目
单选题
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 ";  S”相关问题
  • 第1题:

    阅读以下说明和C语言函数,将应填入(n)处的语句写在对应栏内。

    【说明】

    本程序利用非递归算法实现二叉树后序遍历。

    【函数】

    include<stdio.h>

    include<stdlib.h>

    typedef struct node{/*二叉树的结点数据结构类型*/

    char data;

    struct node *left;

    struct node *right;

    }BTREE;

    void SortTreelnsert(BTREE **tree, BTREE *s)

    {

    if(*tree==NULL)*tree=s;

    else

    if(s->data<(*tree)->data)

    SortTreelnsert((1),s);

    else if(s->data>=(*tree)->data)

    SortTreelnsert((2),s);

    }

    void TraversalTree(BTREE *tree)

    {

    BTREE *stack[1 000],*p;

    int tag[1000],top=0;

    p=tree;

    do{

    while(p !=NULL)

    {

    stack[++top]=p;

    (3);

    tag[top]=0; /*标记栈顶结点的左子树已进行过后序遍历*/

    }

    while(top>0&&(4))/*栈顶结点的右子树是否被后序遍历过*/

    {

    p=stack[top--];

    putchar(p->data);

    }

    if(top>0)/*对栈顶结点的右子树进行后序遍历*/

    {

    (5);

    tag[top]=1;

    }

    }while(top>0);

    }

    void PrintSortTree(BTREE *tree)

    {

    if(tree !=NULL)

    {

    printSortTree(tree->left);

    putchar(tree->data);

    pdntSortTree(tree->right);

    }

    }

    main()

    {

    BTREE *root=NULL, *node;

    char ch;

    ch=getchar();

    while(ch !='')

    {

    node=(BTREE*)malloc(sizeof(BTREE));

    node->data=ch;

    node->left=node->right=NULL;

    SortTreelnsert(&root, node);

    ch=getchar();

    }

    PrintSortTree(root);

    putchar('\n');

    TraversalTree(root);

    }


    正确答案:(1)&(*tree)->left (2)&(*tree)->right (3)p=p->left (4)tag[top]==1 (5)p=stack[top]->right
    (1)&(*tree)->left (2)&(*tree)->right (3)p=p->left (4)tag[top]==1 (5)p=stack[top]->right 解析:本题考查二叉树后序遍历的非递归实现。
    二叉树后序遍历的特点是首先按后序遍历根结点的左子树,然后按后序遍历根结点的右子树,再访问根结点。后序遍历得到的序列根结点总在最后,我们可以用栈结构来实现后序遍历。下面来具体[分析]程序。
    第(1)空很明显是函数SortTreeInsert()的第一个参数,此函数的功能是建立一棵排序二叉树,此空在条件判断语句下面,如果条件成立,说明待插入结点的值小于当前结点的值,根据排序二叉树的生成原理,应该把待插入结点插入到当前结点的左子树中,因此,此空的参数是指向当前结点左子树的地址。这里需要注意的是,这个参数是一个二重指针,需要在一重指针前加一个取地址操作符“&”。所以,此空答案为&(*tree)->left。
    第(2)空也是函数SortTreeInsert()的第一个参数,但调用这个函数的条件与上面不一样,此空是在待插入结点的值大于等于当前结点的值的时候调用函数,根据排序二叉树的生成原理,此时应该把待插入结点插入到当前结点的右子树中,因此,此空答案为&(*tree)->right。
    第(3)空在函数TraversalTree()中,此函数用来对树进行后序遍历,此空在一个循环体中,从程序中可以看出这个循环体的功能是将排序二叉树的所有左子树结点入栈,因此,在当前结点入栈后,接下来是它的孩子结点入栈,所以,此空答案为p=p->left。
    第(4)空是循环的判断条件,其作用在注释中已经给出,是判断栈顶结点的右子树是否被后序遍历过。从上面程序tag[top]=0表示栈顶结点的左子树已进行过后序遍历可以推断出,tag[top]的值是用来标记栈顶结点的左右子树已进行过后序遍历,因此,此空答案为tag[top]==1。
    第(5)空在条件判断语句下面,而条件判断语句为真表明要对栈顶结点的右子树进行后序遍历,那么就应该让当前需处理结点的指针指向栈顶结点的右孩子,而指向当前需要处理结点的指针变量是p,因此,此空答案为p=stack[top]->right。

  • 第2题:

    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
    解析:前序遍历一个二叉树等价于按从树的根部、右子树、右子树查找顺序查找树。

  • 第3题:

    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

  • 第4题:

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


    正确答案:

  • 第5题:

    Which two of these statements correctly describe classic PIM-SM?()

    • A、The IOS default is for a last-hop router to trigger a switch to the shortest path tree as soon as a new source is detected on the shared tree.
    • B、The IOS default is for every one of the routers on the shared tree to trigger a switch to the shortest path tree as soon as a new source is detected on the shared tree.
    • C、The default behavior of switching to the shortest path tree as soon as a new source is detected on the shared tree can be disabled by setting the value in the ip pim spt-threshold command to "infinity."
    • D、The default behavior of switching to the shortest path tree as soon as a new source is detected on the shared tree can be disabled by setting the value in the ip pim spt-threshold command to "zero."

    正确答案:A,C

  • 第6题:

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

    正确答案:C

  • 第7题:

    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

  • 第8题:

    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.

    正确答案:D

  • 第9题:

    单选题
    哪个命令可以在交换机启用RSTP? ()
    A

     spanning-tree mode rapid-pvst

    B

     spanning-tree uplinkfast

    C

     spanning-tree backbonefast

    D

     spanning-tree mode mst


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

  • 第10题:

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


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

  • 第11题:

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


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

  • 第12题:

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

    编译失败


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

  • 第13题:

    下面程序段的输出结果为 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正确。

  • 第14题:

    考虑如下代码:

    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

  • 第15题:

    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

  • 第16题:

    There is a big tree____the house.

    A.in the front of
    B.in front of
    C.in front
    D.at class

    答案:B
    解析:
    暂无解析

  • 第17题:

    What is the Cisco IOS default behavior for switching from the shared tree to the shortest path tree in PIM-SM operations?()

    • A、immediately after receiving the first packet on the shared tree for a given (S,G)
    • B、after receiving over 1 kb/s traffic onthe shared tree for a given (S,G)
    • C、10 seconds after receiving the first packet on the shared tree for a given (S,G)
    • D、30 seconds after receiving the first packet on the shared tree for a given (S,G)
    • E、after receiving over 10 kb/s traffic onthe shared tree for a given (S,G)

    正确答案:A

  • 第18题:

    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

  • 第19题:

    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、编译失败

    正确答案:D

  • 第20题:

    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.

    正确答案:B

  • 第21题:

    单选题
    Which spanning-tree command would cause a PortFast-enabled interface to lose its PortFast-operational status and disable BPDU filtering if it receives BPDUs?()
    A

    spanning-tree guard root

    B

    spanning-tree portfast bpduguard default

    C

    spanning-tree bpduguard enable

    D

    spanning-tree bpdufilter enable

    E

    spanning-tree portfast bpdufilter default


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

  • 第22题:

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


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

  • 第23题:

    单选题
    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
    解析: 暂无解析

  • 第24题:

    单选题
    What is the Cisco IOS default behavior for switching from the shared tree to the shortest path tree in PIM-SM operations?()
    A

    immediately after receiving the first packet on the shared tree for a given (S,G)

    B

    after receiving over 1 kb/s traffic onthe shared tree for a given (S,G)

    C

    10 seconds after receiving the first packet on the shared tree for a given (S,G)

    D

    30 seconds after receiving the first packet on the shared tree for a given (S,G)

    E

    after receiving over 10 kb/s traffic onthe shared tree for a given (S,G)


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