网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
下面是一段javabean程序,该程序的运行结果是 ( ) 。public class NullTest { public static void main(String[] ?args) { int M = 0; String str = null; StringBuffer sb = new StringBuffer("= "); sb.append(str); sb.append(M++); System.out.println(sb.toString()); } }

A.=null
B.=null0
C.=null1
D.=nullM

参考答案

参考解析
解析:本题考查学生对javabean程序的熟悉程度,尤其是数值类型数据和字符串类型数据的掌握情况。M是整型变量,其值为0,str是字符串,sb是字符串空间,其中存放字符“=”,append是字符串添加函数,M++为自增运算符,它的特点是先取M的值作为表达式的值,再进行自增运算。程序的运算过程是:先将null拼接到“=”的后面,得字符串“=null”,再将0作为字符拼接到“=null”的后面,得“=null0”,M自增为1,输出结果为:=null0。
更多 “下面是一段javabean程序,该程序的运行结果是 ( ) 。public class NullTest { public static void main(String[] ?args) { int M = 0; String str = null; StringBuffer sb = new StringBuffer("= "); sb.append(str); sb.append(M++); System.out.println(sb.toString()); } } A.=null B.=null0 C.=null1 D.=nullM” 相关考题
考题 下面是一段javabean程序,该程序的运行结果是(62)。 public class NullTest { public static void main(String[] args) { int M = 0; String str = null; StringBuffer sb = new StringBuffer("= "); sb.append(str); sb.append(M++); System.out.println(sb.toString()); } }A.=nullB.=null0C.=null1D.=nullM

考题 下列程序段的输出结果是【 】。public class Test {void printValue(int m) {do {System.out.println("The value is"+m);}while (--m>10);}public static void main (String args[]) {int i=10;Test t= new Test();t.printValue(i);}}

考题 ( 20 )请阅读下面程序public class ExampleStringBuffer{public static void main ( String[] args ){StringBuffer sb=new StringBuffer ( "test" ) ;System.out.println ( "buffer= "+sb ) ;System.out.println ( "length= "+sb.length ()) ; }}程序运行结果中在 "length=" 后输出的值是A ) 10B ) 4C ) 20D ) 30

考题 阅读下面程序public class ConcatTest{P ublic static void main(String[] args){S tring str1 = " abc " ;S tring str2 = " ABC " ;S tring str3 = str1.concat(str2);S ystem.out.println(str3);}}程序的运行结果是A)abcB)ABCC)abcABCD)ABCabc

考题 请阅读下面程序 public class ExampleStringBuffer{ public static void main(String []args){ StringBuffer sb=new StringBuffer("test"); System.out.println("buffer="+sB) ; System.out.println("length="+sb.length());} } 程序运行结果中在"length="后输出的值A.10B.4C.20D.30

考题 以下Java应用程序执行入口main方法的声明中,正确的是( )。 A.public static void main()B.public static void main(String[] args)C.public static int main(String[] args)D.public void main(String[] args)

考题 下面程序的输出结果是什么? class C1{ static int j=0; public void method(int a){ j++; } } class Test extends C1{ public int method(){ return j++; } public void result(){ method(j); System.out.println(j+method()); } public static void main(String args[]){ new TeA.0B.1C.2D.3

考题 指出下列程序运行的结果public class Example{ String str=newString("good"); char[]ch={'a','b','c'}; public static voidmain(String args[]){ Example ex=new Example();ex.change(ex.str,ex.ch); System.out.print(ex.str+" and ");Sytem.out.print(ex.ch); } public void change(String str,charch[]){ str="test ok"; ch[0]='g'; } } ( )AA good and abcBgood and gbcCtest ok and abcDtest ok and gbc

考题 请阅读下面程序 public class ExampleStringBuffer{ public static void main(String[]args){ StringBuffer sb=new StringBuffer("test"); System.OUt.println("buffer="+sb); System.OUt.println("length="+sb.length );}} 程序运行结果中在"length="后输出的值是( )。A.10B.4C.20D.30

考题 下列程序的输出结果是_______。class Test{public static void main(String args []){int m=6;do{m--:}while(m>0);System.out.println("m="+m);}}

考题 下面代码的运行结果是( )。 public class ConcatTest { public static void main (String[ ] args) { String str1 = "abc"; String str2 = "ABC"; String str3 = str1. coneat(str2); System. out. println(str3); } }A.abcB.ABCC.abcABCD.ABCabc

考题 阅读下面程序 public class My Val{ public static void main(String args[]){ My Val m=new My Val(); m. amethod(); } public void amethod(){ boolean b[]=new Boolean[5]; } } 程序编译或运行结果是A.1B.nullC.D.编译不能过

考题 阅读下面程序 public class ConcatTest { public static void main(String[] args) { String str1="abc"; String str2="ABC": String str3=str1.concat(str2); System.out.println(str3); } } 程序运行的结果是A.abcB.ABCC.abcABCD.ABCabc

考题 下列程序的输出结果是class Test{public static void main(String args[]){int n=7;n 下列程序的输出结果是 class Test{ public static void main(String args[]){ int n=7; n<<=3; n=nn+1|n+2^n+3; n>>=2; System.out.println(n); } }A.0B.-1C.14D.64

考题 执行下列程序后,输出结果为( )。 public class Test { public static void main (String[] args) { StringBuffer sb = new StringBuffer("北京 2008" ); System. out. println ("length =" + sb. length ( ) ); } }A.length = 8B.length = 10C.length = 6D.length = 20

考题 阅读下面程序 public class ConcatTest{ public static void main(String[] args) { String strl = "abc"; String str2 = "ABC"; String str3 = str1.concat(str2); System.out.println(str3); } } 程序的运行结果是:A.abeB.ABCC.abcABCD.ABCabc

考题 以下程序运行后输出的结果是______。public class exl7{public static void main(String args []){int a = 0;for(int j = 1; j <= 20; j++)if(j%5 != 0)a = a + j;System.out.println (a);

考题 指出下列程序运行的结果 ( ) public class Example{ String str=new String("good"); char[]ch={'a','b','c'}; public static void main(String args[]){ Example ex=new Example(); ex.change(ex.otr,ex.ch); System.out.print(ex.str+"and"); System.out.print(ex.ch); } public void change(String str,char ch[])} str="test ok"; ch[0]≈'g'; } }A.good and abcB.good and gbcC.test ok and abcD.test ok and gbc

考题 阅读下面程序 public class MyVal { public static void main(String[]args) { MyVal m=new MyVal(); m.amethod(); } public void amethod() { boolean b[]=new Boolean[5]; } } 程序编译或运行的结果是A.1B.nullC.""D.编译不通过

考题 下列程序通过实现Runnable接口创建一个线程,选择正确的语句填入程序的横线处。 class MyRun implements Runnable { String str; MyRun(String s) { str = s; } public void run() System.out.println(str); } } public class ex40 { public static void main(String[] args) { String name = "实现阶段Runnable 接口"; MyRun my = new MyRun(name); Thread th = th. start ( ); } }A.new MyRun(my)B.new Thread()C.new Thread(my)D.Thread(my)

考题 下列程序运行的结果为:public class Example{String str=new String("good");char[] ch={'a','b','c'};public static void main(String args[]){Example ex=new Example();ex.change(ex.str,ex.ch);System.out.print(ex.str+" and ");Sytem.out.print(ex.ch);}public void change(String str,char ch[]){str="test ok";ch[0]='g';}}A. good and abcB. good and gbcC. test ok and abcD. test ok and gbc

考题 Public class test (  Public static void stringReplace (String text)  (  Text = text.replace (‘j’ , ‘i’);  )  public static void bufferReplace (StringBuffer text)  (  text = text.append (“C”)  )   public static void main (String args[]}  (  String textString = new String (“java”);  StringBuffer text BufferString = new StringBuffer (“java”);  stringReplace (textString);  BufferReplace (textBuffer);  System.out.printLn (textString + textBuffer);  )  )   What is the output?()

考题 public class Test {  public static void main(String[] args) {  String str = NULL;  System.out.println(str);  }  }   What is the result?()  A、 NULLB、 Compilation fails.C、 The code runs with no output.D、 An exception is thrown at runtime.

考题 作为Java应用程序入口的main方法,其声明格式可以是()。A、public static void main(String[] args)B、public static int main(String[] args)C、public void main(String[] args)D、public int main(String[] args)

考题 下面哪些main方法可用于程序执行()A、public static void main(String[]args)B、public static void main(String[]x)C、public static void main(Stringargs[])D、public void main(String[]args)

考题 单选题public class Test {  public static void main(String[] args) {  String str = NULL;  System.out.println(str);  }  }   What is the result?()A  NULLB  Compilation fails.C  The code runs with no output.D  An exception is thrown at runtime.

考题 填空题Public class test (    Public static void stringReplace (String text) (    Text = text.replace („j„ , „i„);    )      public static void bufferReplace (StringBuffer text) (    text = text.append (“C”)   )      public static void main (String args ){  String textString = new String (“java”);    StringBuffer text BufferString = new StringBuffer (“java”);      stringReplace (textString);    BufferReplace (textBuffer);      System.out.printIn (textString + textBuffer);    }   )   What is the output?()

考题 单选题public static void main(String[]args){ String str="null"; if(str==null){ System.out.println("null"); }else(str.length()==0){ System.out.println("zero"); }else{ System.out.println("some"); } } What is the result?()A nullB zeroC someD Compilationfails.E Anexceptionisthrownatruntime.