更多"阅读下面程序 import java.io.*; public c"的相关试题:
[单项选择]请阅读下面程序
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. 10
B. 4
C. 20
D. 30
[单项选择]阅读下面程序
public class VariableUse
public static void main(String[] arqs)
int a;
if(a==8)
int b=9;
System.out.println("a="+
A. ;
B. ;
[单项选择]阅读下面程序
public class Cycle
public static void main(String[] args)
System.out.println(args[0]);
在命令行输入java Cycle one two,该程序输出的结果是
A. Cycle
B. one
C. two
D. 以上三个选项都不对
[单项选择]阅读下面程序
public class Test3
public static void main (String args[])
int x=3,y=4,z=5;
String S="xyz";
System.out.printIn(s+x+y+z);
程序运行的结果是______。
A. xyz12
B. xyz345
C. xyzxyz
D. 12xyz
[单项选择]阅读下面程序
public class Test2
public static void main (String args[])
int a=10, b=4, C=20, d=6;
System.out .printIn(a++*b+c*--d);
程序运行的结果是______。
A. 144
B. 160
C. 140
D. 164
[单项选择]阅读下面程序
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
[单项选择]阅读下面程序
public class Test3
public static void main(String[] args)
int x=3,y=4,z=5;
String s="xyz":
System.out.println(s+x+y+z);
程序运行的结果是
A. xyz12
B. xyz345
C. xyzxyz
D. 12xyz
[单项选择]阅读下面程序
public class Test4
public static void main(String[] args)
int 1=10,j=3;
float m=213.5f,n=4.0f;
System.out.println(i%j);
System.out.println(m%n);
程序运行的结果是
A. 1.0和1.5
B. 1和1.5
C. 1.0和2.5
D. 1和2.5
[单项选择]阅读下面程序
class Test implements Runnable
public static void main (String[] args)
Test t=new Test( );
t.start( );
public void run( )
下列关于上述程序的叙述正确的是______。
A. 程序不能通过编译,因为start()方法在Test类中没有定义
B. 程序编译通过,但运行时出错,提示start()方法没有定义
C. 程序不能通过编译,因为run()方法没有定义方法体
D. 程序编译通过,且运行正常
[单项选择]阅读下面程序
class Test implements Runnable
public static void main(String[] args)
Test t=new Test( );
t.start( ):
public void run( )
下列关于上述程序的叙述正确的是
A. 程序不能通过编译,因为start()方法在Test类中没有定义
B. 程序编译通过,但运行时出错,提示start()方法没有定义
C. 程序不能通过编译,因为run()方法没有定义方法体
D. 程序编译通过,且运行正常
[单项选择]阅读下列程序:
public class Test
public static void main (String args[])
int x=3;
for (int i=1;i<=10; i++) x=x+i/4;
System. out. println(x);
程序的输出结果是( )。
A. 12
B. 13
C. 14
D. 15
[单项选择]阅读下面的程序:
public class Person
int arr[]=new int[10];
public static void main(String args[])
System.out.println(arr[1]);
正确的说法是______。
A. 编译时将产生错误
B. 编译时正确,运行时将产生错误
C. 输出为0
D. 输出为空
[单项选择]下面程序的输出结果是
public class Test
public static void main(String[] args)
int[]array=2,4,6,8,10;
int size=6;
int result=-1:
try
for(int i=0;i<size&&result==-1;i++)
if(array[i]==20)result=i;
catch(ArithmeticException e)
System.out.println("Catch---1");
catch(ArrayIndexOutOfBoundsException e)
System.out.println("Catch---2");
catch(Exception e)
System.out.println("Catch---3");
A. Catch---1 B) Catch一--2 C) Catch---3 D) 以下都不对
[单项选择]阅读下面代码
public class Test
public static void main(String[]args)
System.out.println(2>010:8);
其运行的结果是
A. 2
B. 0
C. 10
D. 8
[单项选择]下面程序段的输出结果为
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
[单项选择]阅读下面代码
public class Test2005
public static void main(String args[])
System.out.println(~(Oxa5)&Oxaa);
其运行结果是
A. Oxa5
B. 10
C. Ox50
D. Oxaa
[单项选择]下面程序段的输出结果为
public class MyClass
public static void main(String args[])
String s="Hello! How are you";
System.out.println(s.LastIndexOf("o",16);
A. 16
B. o
C. u
D. 17