更多“下列代码的输出是()。 public class test{public static void main(String”相关问题
  • 第1题:

    阅读下列代码 public class Test{ public static void main(String args[]){ System.out.println(89>>1); } } 其运行结果是

    A.44

    B.45

    C.88

    D.90


    正确答案:A
    解析:这段程序代码非常简单,就是在屏幕上输出表达式“89>>1”的结果。“>>”是算数右移运算符。“89>>1”是将89的各二进制位右移1位,移到右端的低位被舍弃,最高位则移入原来高位。Java使用补码来表示二进制数,因此89的二进制补码是01011001,则89>>1=00101100,00101100对应的十进制数为44。除此之外,还有一个简便算法。算数右移一位相当于除2取商。89除以2,商是44。所以89>>1的结果是44。因此,本题的正确答案是A。

  • 第2题:

    ( 8 )阅读下列代码

    public class Test2{

    public static void main(String args[]){

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

    其执行结果是 【 8 】 。


    正确答案:

  • 第3题:

    下列代码的执行结果是public class Test{ public int aMethod(){ static int i=0; i++; System.out.println(i); } public static void main(String args[]){ Test test= new Test(); test. aMethod(); }}

    A.编译错误

    B.0

    C.1

    D.运行成功,但不输出


    正确答案:A
    解析:static不能修饰局部变量。

  • 第4题:

    阅读下列代码: public class Test{ public static void main(String args[])[ System. out.println(89>>1 ); } }

    A.44

    B.45

    C.88

    D.90


    正确答案:A

  • 第5题:

    下列语句输出的结果为( )。 public class test { public static void main(String args[]) { byte b=OXA; System.out.println(b); } }

    A.OXA

    B.A

    C.1

    D.10


    正确答案:D

  • 第6题:

    下列代码的执行结果是( )。

    public class Test{

    public int aMethod( ){

    static int i=0;

    i++;

    System.out.println(i):

    }

    public static void main (String args[]){

    Trest test=new Test ( );

    test aMethod( ):

    }

    }

    A.编译错误

    B.0

    C.1

    D.运行成功,但不输出

    B.

    C.

    D.


    正确答案:A

  • 第7题:

    以下代码的输出结果?public class Test{int x=3;public static void main(String argv[]){int x= 012;System.out.println(x);}}

    A.12

    B.012

    C.10

    D.3


    正确答案:C

  • 第8题:

    以下代码的输出结果?public class Test{public static void main(String argv[]){String x="hello";change(x);System.out.println(x);}static void change(String m){m=m+2;}}

    A. hello

    B. hello2

    C. 编译报错

    D. 运行报错,不能将串与整数相加


    正确答案:A

  • 第9题:

    执行以下代码,输出结果的结果是? () public class Test{  public String[] ss = new String[5];    public static void main(String[] args){      System.out.println(ss[1]);  } } 

    • A、 null
    • B、 -1
    • C、 编译时出错
    • D、 运行时报错

    正确答案:C

  • 第10题:

    Public class test (  Public static void main (String args[])  (  System.out.printIn (6 ^ 3);  )  )   What is the output?()


    正确答案:5

  • 第11题:

    填空题
    Public class test (    Public static void main (String args) (   System.out.printIn (6^3);   )   )   What is the output? ()

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

  • 第12题:

    单选题
    执行以下代码,输出结果的结果是? () public class Test{  public String[] ss = new String[5];    public static void main(String[] args){      System.out.println(ss[1]);  } }
    A

     null

    B

     -1

    C

     编译时出错

    D

     运行时报错


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

  • 第13题:

    ( 22 )阅读下列代码

    public class Test{

    public static void main(String args[]){

    System.out.println(89>>1) ;

    }

    }

    其运行结果是

    A ) 44

    B ) 45

    C ) 88

    D ) 90


    正确答案:A

  • 第14题:

    请在下划线处填入代码,是程序正常运行并且输出 “ Hello! ”

    Class Test 【 15 】 {

    Public static void main (String[] arge){

    Test t = new Test();

    t.start();

    }

    Public void run(){

    System.out.println( “ Hello! ” );

    }


    正确答案:

  • 第15题:

    下列程序的输出结果是class Test{public static void main(String args[]){int n=7;n<<=3;n=n&am

    下列程序的输出结果是 class Test{ public static void main(String args[]){ int n=7; n<<=3; n=n&n+1|n+2^n+3; n>>=2; System.out.println(n); } }

    A.0

    B.-1

    C.14

    D.64


    正确答案:C
    解析:本题考查Java中的运算符。首先要清楚程序里面涉及的运算符的含义。“”是按位左移运算符,“&”是按位与运算符,“|”是按位或运算符,“^”是按位异或运算符。题目中整型变量n=7相当于二进制中的111,n=3语句执行后,n值为111000,相当于十进制的56,而语句n=n&n+1|n+2^n+3执行后,n值为57;n>>=2语句执行后,n的值为14,所以选项C正确。

  • 第16题:

    下列代码的执行结果是( )。 public,class Test1 { public static void main(String args[]) { System.out.println(5/2); } }

    A.2.5

    B.2.0

    C.2.50

    D.2


    正确答案:D

  • 第17题:

    下列语句输出结果为( )。 public class test { public static void main(String args[]) { byte b=011; System.out.prinfin(b); } }

    A.B

    B.11

    C.9

    D.011


    正确答案:C

  • 第18题:

    下列程序的输出结果是( )。 public class Test { public static void main (String[] args) { String s="hello"; s.replace ('r','m'); System.out.println(s); } }

    A.hello

    B.HELLO

    C.hemmo

    D.HEMMO


    正确答案:A
    解析:String类的replace (char oldChar,char newChar)函数的作用是返回一个新的字符串,它是通过用newChar替换此字符串中出现的所有oldChar而生成的。返回的是新字符串,但是原字符串变量的值并未发生改变。因此,输出的是“hello”而不是“hemmo”。如果替换语句换为: s=s.replace('l','m');,则输出“hemmo”。

  • 第19题:

    以下代码的输出结果?public class Test{int x=5;public static void main(String argv[]){Test t=new Test();t.x++;change(t);System.out.println(t.x);}static void change(Test m){m.x+=2;}}

    A. 7

    B. 6

    C. 5

    D. 8


    正确答案:D

  • 第20题:

    执行以下代码会输出什么结果?()   public class Test {    StringgetStr(String s){  return s + “hello”;  }  public static void main(String arg[]) {           Test t= new Test();  System.out.println(t.getStr(“LiLei/n”));     } } 

    • A、 编译报错
    • B、 LiLei    hello
    • C、 LiLeihello
    • D、 无任何输出

    正确答案:B

  • 第21题:

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

    正确答案:D,E

  • 第22题:

    下列代码的输出是()。 public class test{public static void main(String args[]) {System.out.print("IBM/n012/63ABC//".length( ));}}

    • A、12
    • B、13
    • C、14
    • D、15

    正确答案:A

  • 第23题:

    单选题
    执行以下代码会输出什么结果?()   public class Test {    StringgetStr(String s){  return s + “hello”;  }  public static void main(String arg[]) {           Test t= new Test();  System.out.println(t.getStr(“LiLei/n”));     } }
    A

     编译报错

    B

     LiLei    hello

    C

     LiLeihello

    D

     无任何输出


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