更多"下列代码的编译或执行结果是______。 public class "的相关试题:
[单项选择]
下列代码的编译或执行结果是()。
public class MyVal
public static void main(String[] args)
MyVal m=new MyVal( );
m.aMethod( );
public void aMethod( )
boolean [] b=new Boolean [5];
System.out.println(b[0]);
A. 1
B. null
C. 0
D. 编译错误
[单项选择]下列代码的编译或执行结果是( )。
public class Myval
public static void main(string args[])
MyVal m=new MyVal( );
m.aMethod( );
public void aMethod( )
boolean b[]=new Boolean[5];
System.out.println(b[0]);
A. 1
B. null
C. 0
D. 编译错误
[单项选择]下列代码编译或执行结果的描述中,正确的是
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[])
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都有可能出现
[单项选择]
下列代码编译或执行结果的描述中,正确的是()。
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[])
TestThread pm1=new TestThread("one");
pm1.start( );
TestThread pm2=new TestThread("Tow");
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. 输出Tow 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(5/2);
System.OUt.println(100%3.O)
}
}
A. 2和1
B. 2和1.0
C. 2.5和1
D. 2.5和1.0
[单项选择]下列代码的执行结果是( )。
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. 构造方法是给对象赋初值,所以没有返回值,且不用void来声明
C. 构造方法一般不能由编程人员显示地直接调用,而是用new来调用
D. 构造方法不可以被重载
[填空题]
下列代码的执行结果是()。
public class Expression
public static void main(String[] args)
int v1=10,v2=99,v3=0;
System.out.println((v1<0)&&(v2/v3)==3);
[单项选择]下列代码的执行结果是( )。
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 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
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