现有:class Test2 fpublic static void main (String [] args) {short a,b,C;a=1;b=2;C=a+b;a+=2;}}以上代码中,哪一句是错误的?()A、a=1;B、C=a+b;C、a+=2;D、shorta,b,C;

题目

现有:class Test2 fpublic static void main (String [] args) {short a,b,C;a=1;b=2;C=a+b;a+=2;}}以上代码中,哪一句是错误的?()

  • A、a=1;
  • B、C=a+b;
  • C、a+=2;
  • D、shorta,b,C;

相似考题
更多“现有:class Test2 fpublic static ”相关问题
  • 第1题:

    下列代码的执行结果是( )。 public class Test2 { public static void main(String arg[]) { System.out.println(100%3); System.out.println(100%3.0); }}

    A.1和1

    B.1和1.0

    C.1.0和1

    D.1.0和1.0


    正确答案:B

  • 第2题:

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

  • 第3题:

    Which statement about static inner classes is true?()

    • A、 An anonymous class can be declared as static.
    • B、 A static inner class cannot be a static member of the outer class.
    • C、 A static inner class does not require an instance of the enclosing class.
    • D、 Instance members of a static inner class can be referenced using the class name of the static inner class.

    正确答案:C

  • 第4题:

    Which thefollowingstatements about static inner classes is true?()

    • A、 An anonymous class can be declared as static.
    • B、 A static inner class cannot be a static member of the outer class.
    • C、 A static inner class does not require an instance of the enclosing class.
    • D、 Instance member of a static inner class can be referenced using the class name of the staticinner class.

    正确答案:C

  • 第5题:

    public class OuterClass {  private double d1  1.0;  //insert code here   }   You need to insert an inner class declaration at line2. Which two inner class declarations are valid?() 

    • A、 static class InnerOne {  public double methoda() {return d1;}  }
    • B、 static class InnerOne {  static double methoda() {return d1;} }
    • C、 private class InnerOne {  public double methoda() {return d1;} }
    • D、 protected class InnerOne {  static double methoda() {return d1;} }
    • E、 public abstract class InnerOne {  public abstract double methoda();  }

    正确答案:C,E

  • 第6题:

    现有:      class Test2  f  public  static void main (String  []  args)  {      short a,b,C;      a=l;      b=2;  C=a+b;      a+=2:      }        以上代码中,哪一句是错误的?()     

    • A、a=1:
    • B、C=a+b;
    • C、a+=2;
    • D、short a,b,C;

    正确答案:B

  • 第7题:

    现有:  class Top  {  static int x=l;  public Top (inty)  {  x*=3;  }      }  class Middle extends Top {      public Middle()  {x+=1;  )  public  static void main (String  []  args)  {      Middle m = new Middle();      System. out .println (x);      }     }      结果为:()     

    • A、1
    • B、2
    • C、3
    • D、编译失败

    正确答案:D

  • 第8题:

    单选题
    现有:  class Top  {     static int X=l;  public Top()  {  x*=3; }     }  class Middle extends Top  {      public  Middle()    {x+=l;  }  public static void main(String  []  args)  {     Middle m=new Middle();    System.out.println (x);    }     }  结果是什么?()
    A

      2

    B

      3

    C

      4

    D

    编译失败


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

  • 第9题:

    单选题
    package test1;  public class Test1 {  static int x = 42;  }  package test2;  public class Test2 extends test1.Test1 {  public static void main(String[] args) { System.out.println(“x = “ + x);  }  }  What is the result?()
    A

     x = 0

    B

     x = 42

    C

     Compilation fails because of an error in line 2 of class Test2.

    D

     Compilation fails because of an error in line 3 of class Test1.

    E

     Compilation fails because of an error in line 4 of class Test2.


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

  • 第10题:

    多选题
    Which statements about static inner classes are true?()
    A

    A static inner class requires a static initializer.

    B

    A static inner class requires an instance of the enclosing class.

    C

    A static inner class has no reference to an instance of the enclosing class.

    D

    A static inner class has access to the non-static members of the outer class.

    E

    Static members of a static inner class can be referenced using the class name of the static inner  class.


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

  • 第11题:

    单选题
    现有:  class Top  {  static int x=l;  public Top (inty)  {  x*=3;  }      }  class Middle extends Top {      public Middle()  {x+=1;  )  public  static void main (String  []  args)  {      Middle m = new Middle();      System. out .println (x);      }     }      结果为:()
    A

    1

    B

    2

    C

    3

    D

    编译失败


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

  • 第12题:

    单选题
    现有: class TestApp{ public static void main (String[] args){ for (int i=0; i
    A

    0123

    B

    012456789

    C

    0123456789

    D

    012


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

  • 第13题:

    阅读下面程序 public class Test2 ______ { public static void main(String[] args) { Thread t=new Test2(); t.start(); } public void run() { System.out.println("How are you."); } } 程序中下画线处应填入的正确选项是

    A.implements Thread

    B.extends Runnable

    C.implements Runnable

    D.extends Thread


    正确答案:D

  • 第14题:

    现有:   class TestMain {      static int x = 2;  static { x = 4; }   static public void main(String[] args) {    int y = x + 1;   System.out.println(y);    }    }    和命令行:  java TestMain    结果为:() 

    • A、 3
    • B、 5
    • C、 编译失败
    • D、 运行时异常被抛出

    正确答案:B

  • 第15题:

    package test1;  public class Test1 {  static int x = 42;  }  package test2;  public class Test2 extends test1.Test1 {  public static void main(String[] args) { System.out.println(“x = “ + x);  }  }  What is the result?() 

    • A、 x = 0
    • B、 x = 42
    • C、 Compilation fails because of an error in line 2 of class Test2.
    • D、 Compilation fails because of an error in line 3 of class Test1.
    • E、 Compilation fails because of an error in line 4 of class Test2.

    正确答案:C

  • 第16题:

    现有: class TestApp{ public static void main (String[] args){ for (int i=0; i

    • A、0123
    • B、012456789
    • C、0123456789
    • D、012

    正确答案:D

  • 第17题:

    Which statements about static inner classes are true?()

    • A、 A static inner class requires a static initializer.
    • B、 A static inner class requires an instance of the enclosing class.
    • C、 A static inner class has no reference to an instance of the enclosing class.
    • D、 A static inner class has access to the non-static members of the outer class.
    • E、 Static members of a static inner class can be referenced using the class name of the static inner  class.

    正确答案:C,E

  • 第18题:

    1. public class OuterClass {  2. private double d1 = 1.0;  3. // insert code here  4. }  Which two are valid if inserted at line 3?()  

    • A、 static class InnerOne { public double methoda() { return d1; } }
    • B、 static class InnerOne { static double methoda() { return d1; } }
    • C、 private class InnerOne { public double methoda() { return d1; } }
    • D、 protected class InnerOne { static double methoda() { return d1; } }
    • E、 public abstract class InnerOne { public abstract double methoda(); }

    正确答案:C,E

  • 第19题:

    单选题
    现有:class Test2 fpublic static void main (String [] args) {short a,b,C;a=1;b=2;C=a+b;a+=2;}}以上代码中,哪一句是错误的?()
    A

    a=1;

    B

    C=a+b;

    C

    a+=2;

    D

    shorta,b,C;


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

  • 第20题:

    单选题
    Which thefollowingstatements about static inner classes is true?()
    A

     An anonymous class can be declared as static.

    B

     A static inner class cannot be a static member of the outer class.

    C

     A static inner class does not require an instance of the enclosing class.

    D

     Instance member of a static inner class can be referenced using the class name of the staticinner class.


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

  • 第21题:

    单选题
    现有:      class Test2  f  public  static void main (String  []  args)  {      short a,b,C;      a=l;      b=2;  C=a+b;      a+=2:      }        以上代码中,哪一句是错误的?()
    A

    a=1:

    B

    C=a+b;

    C

    a+=2;

    D

    short a,b,C;


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

  • 第22题:

    单选题
    现有:  class Test2  f  public static void main (String  []  args)  {      boolean X= true;      boolean y=false;      short Z=20;      if((x==true)  &&  (y=true))  z++;     if((y==true) ||  (++z==22))  z++;      System. out .println( "z="+z);      }      结果是什么?()
    A

    Z=21

    B

    Z=22

    C

    Z=23

    D

    Z= 24


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

  • 第23题:

    单选题
    Which statement about static inner classes is true? ()
    A

     An anonymous class can be declared as static.

    B

     A static inner class cannot be a static member of the outer class.

    C

     A static inner class does not require an instance of the enclosing class.

    D

     Instance members of a static inner class can be referenced using the class name of the static inner class.


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