更多"请阅读下面程序 import java.io. *; public c"的相关试题:
[单项选择]阅读下面程序
import java.io.*;
public class TypeTransition
public static void main (String args[])
char a='h';
int i=100;
int j=97;
int aa=a+i;
System.out.printIn("aa="+aa);
Char bb=(char)j;
System.out.printIn("bb="+bb);
如果输出结果的第二行为bb=a,那么第一行的输出是( )。
A. aa=I
B. aa=204
C. aa=v
D. aa=156
[单项选择]请阅读下面程序
public class ExampleStringBuffer
public static void main (String[]args)
StringBuffer sb=new StringBuffer("test");
System.out.printIn("buffer="+sb);
System, out.printIn("length="+sb.length( ));
程序运行结果中在“length=”后输出的值是______。
A. 10
B. 4
C. 20
D. 30
[单项选择]请阅读下面程序
public class ForLoopStatement
public static void main (String[] args)
int i;j;
for(i=1;i<5;j++)//i循环
for(j=1;j<=i;j++)//j循环
System.out.print(i+"*"+j+"="+i*j+" ");
System.out.printIn( );
程序完成后,i循环和j循环执行的次数分别是______。
A. 4,10
B. 8,9
C. 9,8
D. 10, 10
[单项选择]
请阅读下面程序
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 ForLoopStatement {
public static void main(string []args){
int i,j;
for (i=1; i<5; i++) { //i循环
for (j=1;j<=i;j++) //j循环
System.out.print(i+"×"+j+"="+i*j+" ");
System.out.println( );
}
}
}
程序完成后,i循环和j循环执行的次数分别是()
A. 4,10
B. 8,9
C. 9,8
D. 10,10
[单项选择]请阅读下面程序
public class ThreadTest
public static void main(String args[])throws Exception
int i=0:
Hello t=new Hello( );
_________;
while(true)
System.out.println("Good Morning"+i++);
if(i==2&&t.isAlive( ))
System.out.println("Main waiting for Hello!");
t.join( );//等待t运行结束
if(i==5)break;)
class Hello extends Thread
int i;
public void run( )
while(true)
System.out.println("Hello"+i++);
if(i==5)break;
为使该程序正确执行,下画线处的语句应是( )。
A. sleep()
B. yield()
C. interrupt()
D. start()
[填空题]请阅读下面程序
public class Test {
public static void main (String[] args) {
int i,j;
for (i=1;i<5;i++) {
for (j=1;j<=i;j++)
system.out.print (i+"X"+j+"="+i*j+" ");
System.out.println( );
}
}
}
程序执行完后,i循环和j循环执行的次数分别是 【12】 。
[单项选择]
请阅读下面程序
public class ThreadTest{
public static void main(String args[]) {
Thread t1=new Thread(new Hello( ));
Thread t2=new Thread(new Hello( ));
t1.start( );
t2.start( );
}
}
class Hello implements Runnable {
int i;
public void run( ) {
while(true) {
System.out.prinfin("Hello"+i++);
if(i=5) break;
}
}
}
该程序创建线程使用的方法是()
A. 继承Thread类
B. 实现Runnable接口
C. t1.start()
D. t2.start()
[单项选择]
请阅读下面程序
public class ThreadTest {
public static void main(String args[]) throws Exception{
int i=0;
Hello t=new Hello( );
____;
while(true) {
System.out.println("Good Moming"+i++);
if (i==2 && t.isAlive( )) {
System. out.println("Main waiting for Hello!");
t.join( ); //等待t运行结束
}
if(i==5) break;
}
}
}
class Hello extends Thread {
int i;
public void run( ) {
while(true){
System.out.println("Hello"+i++);
if (i==5) break;
}
}
}
为使该程序正确执行,下划线处的语句应是()
A. sleep()
B. yield()
C. interrupt()
D. start()
[单项选择]
请阅读下面程序
public class OperatorsAndExpressions {
void residual( ) {
int i=100, j=30;
float m=563.5f, n=4.0f;
System.out.println(i%j);
System.out.println(m%n);
}
public static void main(String args[]) {
OperatorsAndExpressions OperAndExp=new OperatorsAndExpressions( ); //取模运算符在整数和浮点数中的应用
OperAndExp.residual;
}
} 程序运行结果是()
A. 10 3.5
B. 20 2.5
C. 10 4.5
D. 20 3.5
[单项选择]
请阅读下面程序
import java.io.*;
public class ExceptionCatch {
public static void main(String args[]) {
try{
FilelnputStream fis=new FilelnputStream("text");
System.out.println("content of text is:");
}
catch(FileNotFoundException e) {
System.out.println(e);
System.out.println("message:"+e.getMessageO);
e.printStackTrace(System.out);
}
____{
System.out.println(e);
}
}
}
为保证程序正确运行,程序中下划线处的语句应是()
A. catch(FilelnputStream fis)
B. e.printStackTrace()
C. catch(IOException e)
D. System.out.println(e)
[单项选择]阅读下面程序
public class ForLoopStatement
public static void main(String[] args)
int i,j;
for(i=1;i<5;i++) //i循环
for(j=1;j<=i;j++)System.out.print(i+"*"+j+"="+i*j+" "); //j循环
System.out.println( );
程序完成后,i循环和J循环执行的次数分别是
A. 4,10
B. 8,9
C. 9,8
D. 10,10
[单项选择]阅读下面程序
public class OperatorsAndExpressions
void equalsMethodl( )
String s1=new String("how are you");
String s2=new String("how are you");
System.out.println(s1==s2);
public static void main(String args[])
OperatorsAndExpressions OperAndExp=new OperatorsAndExpressions( );
OperAndExp. equalsMethod1( );
程序运行结果是( )。
A. ==
B. true
C. false
D. equal
[单项选择]阅读下面程序
public class Increment
public static void main(stringargs[])
int c;
c=5:
System.out.println(c);
System.out.println(c++);
System.out.println(c);
程序运行结果是( )。
A. 5
B. 5
C. 6
D. 6
[单项选择]阅读下面程序:
public class ThreadTest
public static void main(String args[]) throws Exception
int i=0;
Hello t=new Hello( );
______;
While(true)
System.out.println("Good Morning"+i++);
if(i==2&&t.isAlive( ))
System.out.println("Main waiting for Hello!");
t.join( ); //等待t运行结束
If(i==5)break:
class Hello extends Thread
int i;
public void run( )
while(true)
System.out.println("Hello"+i++):
If(i==5)break;
为使该程序正确执行,下画线处的语句应是
A. sleep()
B. yield()
C. interrupt()
D. start()
[单项选择]阅读下面程序 public class VariableUse { public static void main(String[] arqs) { int a; if(a==8) { int b=9; System.out.println("a="+a); System.out.println("b="+b); } System.out.println("a="+a); System.out.println("b="+b): } } 该程序在编译时的结果是
A. 变量a未赋值
B. 第二个System.out.println("b="+b);语句中,变量b作用域有错
C. 第二个System.out.println("a="+a);语句中,变量a作用域有错
D. 第一个System.out.println("b="+b);语句中,变量b作用域有错