更多"阅读下面程序 public class VariableUse { "的相关试题:
[简答题]阅读下列程序
public class VariableUse
public static void main(String[]args)
int a;
if(a==8)
int b=9;
System.out.println(’a=’+a);
Systern.out.println(’b=’+b);
System.out.println(’a=’+a);
System.out.println(’b=’+b);
该程序在编译时的结果是( )。
[单项选择]
阅读下列程序
public class VariableUse{
public static void main(String[]args){
inta;
if(a==8){
intb=9;
System.out.println("a"="+a);
System.out.println("b="+b);
}
System.out.println("a="+a);
System.out.println("b="+b);
}
}
该程序在编译时的结果是()
A. 变量a未赋值
B. 第二个Systeouprintln("b="+语句中,变量b作用域有错
C. 第二个Systeouprintln("a="+语句中,变量a作用域有错
D. 第一个Systeouprintln("b="+语句中,变量b作用域有错
[单项选择]阅读下面程序
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. abc
B. ABC
C. abcABC
D. ABCabc
[单项选择]阅读下面程序:
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 Test3
public static void main(String args[])
int x=3, y=4, z=5;
String s="xyz";
System.out.primln(s+x+y+z);
程序运行的结果是
A. xyzl2
B. xyz345
C. xyzxyz
D. 12xyz
[单项选择]请阅读下面程序
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 Increment {
public static void main( String args[] ){
int c;
c=5;
System.out.println(C) ;
System.out.println(c++);
System.out.println(C) ;
}
}
程序运行结果是()
A. 5 6 6
B. 5 5 6
C. 6 7 7
D. 6 6 6
[单项选择]阅读下面程序
public class Test4
public static void main (String args[])
int i=10, j=3;
float m=213.5f,n=4.0f
System.out.printIn (i%j);
System.out.printIn (m%n);
程序运行的结果是______。
A. 1.0和1.5
B. 1和1.5
C. 1.0和2.5
D. 1和2.5
[填空题]请阅读下面程序
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[]) 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 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 Test1
public static void main(String[] args)
System.out.println(34+56-6);
System.out.println(26*2-3);
System.out.println(3*4/2);
System.out.println(5/2);
程序运行的结果是
A. 84
B. 90
C. 84
D. 68
[单项选择]
阅读下面程序
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. 1
B. null
C. " "
D. 编译不能过
[单项选择]阅读下面的程序
public class ConcatTest
public static void mian (String[]args)
String str1="abc";
String str2="ABC";
String str3=str1.concat(str2);
System.out.printIn(str3);
程序的运行结果是______。
A. abc
B. ABC
C. abcABC
D. ABCabc
[单项选择]
阅读下面程序
public class Test2______ {
public static void main(String[] args){
Thread t=new Test2( );
t. start( );
}
public void run( ){
System. out. priatln("How are you. ");
}
}
在程序下画线处填入的正确的选项是()
A. implements Thread
B. extends Runnable
C. implements Runnable
D. extends Thread