题目内容

在(1)~(3)处填上适当的语句,使程序能正常运行classPerson{publicvoidshow(){}}(1){publicvoidshow(){System.out.println("Student");}}classTeacherextendsPerson{(2){System.out.println("Teacher");}}publicclassDemo{publicstaticvoidmain(String[]args){(3)p.show();p=newStudent();p.show();p=newTeacher();p.show();}}

查看答案
更多问题

读下面程序,写出程序运行结果。classPoint{intx;publicPoint(){x=0;}publicPoint(intx){this.x=x;}publicvoidshow(){System.out.println(x);}}classSPointextendsPoint{inty;publicSPoint(){y=0;}publicSPoint(intx,inty){super(x);this.y=y;}publicvoidshow(){System.out.println(x+","+y);}}publicclasstempDemo{publicstaticvoidmain(String[]args){Pointp=newPoint();p.show();Pointp1=newPoint(2);p1.show();SPointsp=newSPoint();sp.show();SPointsp1=newSPoint(2,3);sp1.show();}}运行结果为:

读下面程序,写出程序运行结果。classPoint{intx=1;publicvoidshow(){System.out.println(x);}}classSPointextendsPoint{inty=2;publicvoidshow(){System.out.println(x+","+y);}}classPPointextendsPoint{intz=3;publicvoidshow(){System.out.println(x+","+z);}}publicclasstempDemo{publicstaticvoidmain(String[]args){Pointp;p=newPoint();p.show();p=newSPoint();p.show();p.x=2;p.show();p=newPPoint();p.show();}}运行结果为:

在(1)~(3)处填上适当的语句,使程序能正常运行。.(1)classEmployee{publicabstractvoidshow();}classSalEmpextendsEmployee{publicvoidshow(){System.out.println("SalEmp");}}classTelEmpextendsEmployee{(2){System.out.println("TelEmp");}}publicclassDemo{publicstaticvoidmain(String[]args){SalEmpp=newSalEmp();p.show();(3)p1=newTelEmp();p1.show();}}

读下面程序,写出程序运行结果。classPerson{inta,b;publicPerson(inta,intb){System.out.println("a,b:"+a+b);}}classStudentextendsPerson{intc;publicStudent(inta,intb,intc){super(a,b);this.c=c;System.out.println("c:"+c);}publicvoidshow(){System.out.println("a,b,c:"+a+b+c);}}publicclassclassDemo1{publicstaticvoidmain(String[]args){Personp1=newPerson(1,2);Studentp2=newStudent(2,3,4);p2.show();}}运行结果为:

答案查题题库