更多"关于下列代码编译或执行结果的描述中,正确是______。 publi"的相关试题:
[单项选择]关于下列代码编译或执行结果的描述中,正确的是( )。
public class Test
public static void main(String args[])
TestThread pm1=new TestThread("One")
pm1.start( );
TestThread pm2=new TestThread("Two")
pm2.start( );
class TestTbread extends Thread(
private String sTname="";
TestThread(String s)
sTname=s;
public void run( )
for(int i=0;i<2;i++)
try
sleep(1000);
catch(InterruptedException e)
system.out.print(sTname+"");
A. 不能通过编译,TestThread类中不能定义变量和构造方法
B. 输出One One Two Two
C. 输出Two One One Two
D. 选项B或C都有可能出现
[单项选择]下列代码的执行结果是 public class Test public int aMethod( ) static int i=0; i+ +; System.out.println(i); public static void main(String args[ ]) Test test = new Test( ); test.aMethod( );
A. 编译错误
B. 0
C. 1
D. 运行成功,但不输出
[单项选择]下列代码的执行结果是( )。
public class Test
public static void main(String args[])
System.out.println(7/2);
A. 3.5
B. 3
C. 3.0
D. 3.50
[单项选择]下列代码的执行结果是( )。
public class Test
public static void main (String args[])
int a=3,b=5,c=8;
String s="abc";
System.out.println(a+b+s+c);
A. 35abc8
B. 8abc8
C. 16
D. abc
[单项选择]下列代码的执行结果是( )。
public class Test
public static void main String args[])
String s1=new String("welcome");
String s2=new String("welcome");
System.out.println(s1==s2);
System.out.println(s1.equals(s2));
A. false,false
B. false,true
C. true,true
D. true,false
[单项选择]下列代码的执行结果是( )。
public class Test
public int aMethod( )
static int i=0;
1++;
System.out.println(i):
public static void main (String args[])
Trest test=new Test ( );
test aMethod( ):
A. 编译错误
B. 0
C. 1
D. 运行成功,但不输出
[单项选择]
下列代码的执行结果是()。
public class Test
public static void main(String[] args)
int[] x=0,1,2,3;
for(int i=0;i<3;i+=2)
try
System.out.println(x[i+2]/x[i]+x[i+1]);
catch(ArithmeticException e)
System.out.println("error1");
catch(Exception e)
System.out.println("error2");
A. error1
B. error2
C. error1
D. 2
[单项选择]下列代码的执行结果是()public class Test { public static void main(String[] args) { int[] x={0,1,2,3}; for(int i=0;i<3;i+=2){ try{ System.out.println(x[i+2]/x[i]+x[i+1]); }catch(ArithmeticException e){ System.out.println("error1"); }catch(Exception e){ System.out.println("error2"); } } } }
A. error1
B. error2
C. error1 error2
D. 2 error2
[单项选择]下列代码的执行结果是 ( )
public class Test2public static void main(String args[])int a=4,b=6,c=8;
String s="abc";
System.out.println(a+b+s+c);
A. "ababcc"
B. "464688"
C. "46abc8"
D. "10abc8/
[单项选择]下列代码的执行结果是:( ) public class Test1 public static void mian(String args[]) float t=9.0f int q=5; System.out.println((t++)*(--q));
A. 40
B. 40.0
C. 36
D. 36.0
[单项选择]下列代码的执行结果是( )。 public class Test 2 public static void main (String arg[]) System.out.println(100%3); System.out.println(100%3.0);
A. 1和1
B. 1和1.0
C. 1.0和1
D. 1.0和1.0
[单项选择]下列代码的执行结果是( )。 public class test5 public static void main (String args[]) String s1=new String("hello"); String s2=new String("hello"); System.out.prim(s1==s2); System.out.print(","); System.out.println(s1.equals(s2));
A. true,false
B. true,true
C. false,true
D. false,false
[单项选择]下列代码的执行结果是( )。
public class Test
{
public static void main(String args[])
{
System.out.println(5/2);
System.OUt.println(100%3.O)
}
}
A. 2和1
B. 2和1.0
C. 2.5和1
D. 2.5和1.0
[单项选择]下列代码编译或执行结果的描述中,正确的是
class Test{
public static void main(String args[]){
TestThread pm1 = new TestThread("One");
pm1.start( );
TestThread pm2 = new TestThread("Two");
pm2.start( );
}
}
class TestThread extends Thread{
private String sTname="";
TestThread(String s){
sTname = s;
}
public void run( ){
for(int i=0;i<2;i++){
try {
sleep(1000);
} catch (InterruptedException e) {}
System.out.println(sTname+" ");
}
}
}
A. 不能通过编译,TestThread类中不能定义变量和构造方法
B. 输出 One One Two Two
C. 输出 Two One One Two
D. 选项B或C都有可能出现
[单项选择]下列代码段的执行结果是( )。
public class Test
public static void main(String args[])
String s1=new String("hello");
String s2=new String"hello");
System.out.println(s1==s2);
System.out.println(s1.equal(s2));
A. true false
B. true true
C. false true
D. false false