更多"请写出下面程序的运行结果: public class Test ext"的相关试题:
[填空题]请写出下面程序的运行结果:
public class Test extends TT{
public static void main(String args[])(
Test t=new Test("Tom.");
}
public Test(SUing s){
super(s);
System.out.print("How are you");
}
public Test( ){
this("I am Jack.");
}
}
class TT{
public TT( ) {
System,out.print("Hi!");
}
public TT(String s){
this( );
System.out.print("I am"+s);
}
}
结果: 【15】 。
[填空题]请写出下面程序的运行结果:
public class Test extends TT
public static void main(String args[])
Test t=new Test("Tom.");
public Test(String s)
super(S);
System.out.print("How are you");
public Test( )
this("I am Jack.");
class TT
public TT( )
System.out.print("Hi!");
public TT(String s)
this( );
System.out.print("I am" +s);
结果:______。
[填空题]请写出下面程序的运行结果:
public class Test extends TT{
public static void main(String args[]){
Test t=new Test("Tom.");
}
public Test(String s){
super(s);
System.out.print("How are you");
}
public Test( ){
this("I am Jack.");
}
}
class TT{
public TT( ){
System.out.print("Hi!");
}
public TT(String s){
this( );
System.out.print("I am"+s);
}
}
结果【 】。
[填空题]请写出下面程序的运行结果:
public class Test extends TT{
public static void main(String args[]){
Test t=new Test("Tom.");
}
public Test(String s){
super(S);
System.out.print("How are you");
}
public Test( ){
this("I am Jack.");
}
}
class TT{
public TT( ){
System.out.print("Hi!");
}
public TT(String s){
this( );
System.out.print("I am" +s);
}
}
结果:______。
[单项选择]阅读下面程序
1public class Try extends Thread 2public static void main(String args[])
3Tryt=new Try( );
4t.start( );
5
6
7publicvoidrun(intj)
8inti=0;
9while(i<5)
10System.out.println("祝你成功!");
11 i++;
12
13
14
该程序要求打印5行“祝你成功!”,必须改正程序中的某行代码,程序才能完成。选择正确的修改是( )。
A. 将第1行的extendsThread改为implementsRunnable
B. 将第3行的newTry()改为newThread()
C. 将第4行t.start()改为start(t)
D. 将第7行的publicvoidmn(intj)改为publicVoidmn()
[单项选择]阅读下面程序
1 public class Try extends Thread{
2 public static void main(String args[]){
3 Try t=new Try( );
4 t.start( );
5 }
6
7 public void run(int j){
8 int i=0;
9 while(i<5){
10 System.out.println(“祝你成功!”);
11 i++;
12 }
13 }
14 }
该程序要求打印5行“祝你成功!”,必须改正程序中的某行代码,程序才能完成。选择正确的修改是【 】
A. 将第1行的extendsThread改为implementsRunnable
B. 将第3行的newTry()改为newThread()
C. 将第4行t.start()改为start(t)
D. 将第7行的publicvoidrun(intj)改为publicvoidrun()
[单项选择]阅读下面程序
1 public class Try extends Thread
2 public static void main(String args[])
3 Try t=new Try( );
4 t.start( );
5
6
7 public void run(int j)
8 int i=0;
9 while(i<5)
10 System.out.println("祝你成功!");
11 i++:
12
13
14
该程序若能打印5行“祝你成功!”,必须改正程序中的某行代码,选择正确的修改是
A. 将第1行的extends Thread改为implements Runnable
B. 将第3行的new Try()改为new Thread()
C. 将第4行的t.start()改为start(t)
D. 将第7行的public void run(int j)改为public void run()
[简答题]
阅读下列程序,请写出该程序的输出结果。
class Test33 {
static int merger(int [] a, int []b, int []c){
int i = 0, j = 0, k = 0;
while(i < a.length && j < b.length) {
if(a[i] < b[j])c[k++] = a[i++];
else c[k++] = b[j++];
}
while(i < a.length) c[k++] = a[i++];
while(j < b.length) c[k++] = b[j++];
return k;
}
public static void main(String[] args) {
int a[] = {3, 6, 9};
int b[] = { 1, 2, 5};
int []c = new int[100];
int p = merger(a, b, c);
for(int k = 0; k < p; k++)
System.out.print(c[k]+ (k < p-1 " ":"/n"));
}
[单项选择]
阅读和理解下面程序段:
class Manager extends Employee{
public Manager(String n,double s,int year,int month,int day) {
super(n,s,year,month,day);
bonus=O;
}
public double getSalary( ){
double baseSalary=super,gerSalary( );
return baseSalary+bonus;
}
public void setBonus(double b);
{
bonus=b;
}
private double bonus;
}
Manager是Employee的子类,其理由是()
A. Manager的适用范围较宽
B. extends关键字声明
C. Manager的域减小了
D. 雇员是一个经理
[简答题]阅读下列程序,请写出程序的运行结果。
public class C
public static void main(String[] args)
String text="public static void main(String[] args)";
int theCount=0;
int index=-1;
String theStr="i";
index=text. indexOf(theStr);
while(index>=0)
++theCount;
index+=theStr. length( );
index=text. indexOf(theStr,index);
System. out. println("The Text contains"+theCount+"i");
[单项选择]阅读下列程序:
class ThreadTest extends Thread
public static void main(String[]args)
Thread t=new Thread(this);
t.start( );
public void run( )
System.out.print("A thread test.");
对该程序而言,正确结论是 ( )
A. 该程序能够通过编译并打印输出“A thread test.”
B. 该程序能够通过编译,但运行时将不调用ThreadTest类中的run()方法,因此不产生任何输出
C. 该程序存在编译错误,因为在main()方法中不能使用this指针
D. 上述选项都不正确
[单项选择]下面程序片段的运行结果是( )。
public class Test
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 Test implements Runnable
public static void main(String[]args)
_______________________________________;
t. start( );
public void mR( )
System. out. println("Hello!");
}
在程序下画线处填入正确选项是
A. Test t=flew Test()
B. Thread t=new Thread();
C. Thread t=new Thread(new Test());
D. Test t=new Thread();
[单项选择]阅读下面程序
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. 程序编译通过,且运行正常