System.out.println()输出后是不加换行的,而System.out.print()输出后是加换行的。
第1题:
下面程序执行后的输出结果为( )。 public class fun { public static void main(String args[]) { String greets="How are you!"; String s=greets.substring(0,3); System.out.println(S); } }
A.How
B.are.
C.you
D.how ate you!
第2题:
下列程序运行后的输出结果为( )。 public class Test { public static void main (String args[]) { int i,j,p,s; s=0; for (i=1;i<=4; i++) { p=1; for(j=1;j<=i:j++) p=p*j; s=s+p; } System.out.println(s); } }
A.46
B.33
C.30
D.40
第3题:
执行以下代码后,下面哪些描述是正确的()publicclassStudent{privateStringname=Jema”;publicvoidsetName(Stringname){this.name=name;}publicStringgetName(){returnthis.name;}publicstaticvoidmain(String[]args){Students;System.out.println(s.getName());}}
A.输出null
B.第10行编译报错
C.第11行编译报错
D.输出Jema
第4题:
下列语句输出结果为( )。 public class test { public static void main(StringArgsl[]) { String s1=new String("How"); String s2=new String("How"); System.out.println(!(s1==s2)); } }
A.false
B.true
C.1
D.0
第5题:
有下列程序段 public class fun { public static void main(String args[]) { char b[]="Hello,you"; b[5] = 0; System.out.println(s); } 执行此程序后,得到的输出结果是( )。
A.Hello, you
B.Hello0you
C.Hello
D.0
第6题:
下面程序段的输出结果为 public class MyClass { public static void main(String args[]) { String s="Helto! How are you?"; System.out.println(s.lastlndexOf("o",16)); } }
A.16
B.o
C.u
D.17
第7题:
顺序执行下列两条语句,输出结果是______。
String s="You are a pretty boy!";System.out.println(s.length( ));
第8题:
A.编译报错
B.2
C.1
D.3
第9题:
下面程序输出的结果是什么? ( ) public class Quiz2 { public static void main(String args[]) { try {throw new MyException(); }catch(Exception e) { System.out.println("It's caught!"); }finally{ System.out.println("It's finally caught!"); } } } class MyException extends Exception{}
A.It's finally caught!
B.It's caught!
C.It's caught!/It's finally caught!
D.无输出
第10题:
有如下代码段 public class OperatorAndExceptions { public static void main(String args[ ] { int i=10,j=15; System.out.println(i==j); String s1 = new String("how are you!"); String s2=new String("how are you!"); System.out.println(s1==s2); } } 其输出为( )。
A.true false
B.true true
C.false true
D.false false