//线程A等待线程B的执行public class Dengdai{public static void main(String args[ ]){KThread a=new KThread ();a.threadA.start();}}class KThread implements Runnable{Thread threadA,threadB;String content[ ]={"今天晚上,","六点钟开始","在201实验室,","全班同学","上java实验!"};KThread(){(1)(2)threadB.setName("老师");}public void run(){if(Thread.currentThread()==threadA){System.out.println("我等"+threadB.getName()+"讲完我在提问!");threadB.start();while(threadB.isAlive()==false){}try{ (3) //线程threadA开始等待threadB结束}catch(InterruptedException e){}System.out.printf("\n老师:\"这个问题该怎么解决,谢谢老师\"");}else if(Thread.currentThread()==threadB){System.out.println(threadB.getName()+"说:");for(int i=0;i
查看答案
写出下列程序段的运行结果class Parent {String one, two;public Parent(String a, String b){one = a;two = b;}public void print(){ System.out.println(one); }}public class Child extends Parent {public Child(String a, String b){super(a,b);}public void print(){System.out.println(one + " to " + two);}public static void main(String args[]){Parent p = new Parent("south", "north");Parent t = new Child("east", "west");p.print();t.print();}}
写出下列程序段的运行结果class change{void changeint(int x){x++;} public static void main(String args[]){int a=2;System.out.println("Before changed:"+"a="+a);change cxz=new change();cxz.changeint(a);System.out.println("After changed:"+"a="+a);}}
写出下列程序段的运行结果abstract class Shape {abstract void display();}class Circle extends Shape {void display() {System.out.println("Circle");}}class Rectangle extends Shape {void display() {System.out.println("Rectangle");}}class Triangle extends Shape {void display() {System.out.println("Triangle");}}public class AbstractClassDemo{public static void main(String args[]){(new Circle()).display();(new Rectangle()).display();(new Triangle()).display();}}
写出下列程序段的运行结果public class TestArray{public static void main(String args[ ]){int i , j ;int a[ ] = { 5,9,6,8,7};for ( i = 0 ; i < a.length-1; i ++ ) {int k = i;for ( j = i ; j < a.length ; j++ )if ( a[j]