题目内容

8.4阅读程序,写出运行结果classStudent{privateStringname;publicstaticintage=20;publicStudent(Stringname){this.name=name;age++;}publicvoidshow(){System.out.println("name="+name+",age="+age);}}publicclasst{publicstaticvoidmain(String[]args){Students1=newStudent("张同学");s1.show();Students2=newStudent("赵同学");s2.show();s1.show();}}

查看答案
更多问题

8.5阅读程序,写出运行结果classPoint{intx=1;staticinty=2;publicvoidshow(){System.out.println(x+","+y);}}publicclasstempDemo{publicstaticvoidmain(String[]args){Pointp1=newPoint();p1.show();p1.x=2;p1.y=3;Pointp2=newPoint();p2.show();p1.show();p1.y=5;p2.show();}}

8.6阅读程序,写出运行结果classDemo{inta=0;staticintb=0;publicDemo(){++b;System.out.println("a,b:"+a+b);}publicDemo(inta){this();this.a=a;System.out.println("a,b:"+a+b);}}publicclassclassDemo1{publicstaticvoidmain(String[]args){Demod1=newDemo();d1.a=3;System.out.println("a,b:"+d1.a+d1.b);Demod2=newDemo(2);Demod3=newDemo();}}

8.7阅读程序,写出运行结果classStudent{StringstuName="学生";staticintNo=0;publicStudent(){No++;System.out.println(stuName+No);}publicStudent(inta){No=a;System.out.println(stuName+a);}publicvoidshow(){System.out.println(stuName+No);}}classDemo{publicstaticvoidmain(String[]args){Studentst1=newStudent();st1.show();Studentst2=newStudent(2);st2.show();st1.show();}}

8.8某公司正进行招聘工作,被招聘人员需要填写个人信息,编写“个人简历”的封装类。包括如下属性和对属性进行操作的方法。Stringxm;//姓名Stringxb;//性别intnl;//年龄Stringjtzz;//家庭住址Stringxl;//学历//输入上述信息显示上述信息

答案查题题库