现有:class Test2 fpublic static

题目

现有: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;
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

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

A.implements Thread

B.extends Runnable

C.implements Runnable

D.extends Thread


正确答案:D
解析:Thread类是多线程基类,多线程启动类必须继承此类。而实现Runnable接口的类能作为多线程的一个执行任务,一般作为参数传给新的Thread类。

第2题:

下列代码的执行结果是( )。 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

第3题:

( 8 )阅读下列代码

public class Test2{

public static void main(String args[]){

System.out.println(5/2);}}

其执行结果是 【 8 】 。


正确答案:

第4题:

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

第5题:

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

第6题:

Static Nested Class 和 Inner Class 的不同。


正确答案:

 

参见前面的什么是内部类的那道题

第7题:

阅读下面程序 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

第8题:

阅读下面程序

public class Test2{

public static void main(String args[]){

int a=10,b=4,c=20,d=6;

System.out.println(a++*b+c*-d);

}

}

程序运行的结果是

A)144

B)160

C)140

D)164


正确答案:C

第9题:

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

第10题:

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

更多相关问题