62,635
社区成员




package shuren.ren;
//class Teacher
class Teacher
{
public Teacher()
{
System.out.println("父类无参构造");
}
public Teacher (String str)
{
System.out.println(str);
}
}
//class Student
class Student extends Teacher
{
public Student()
{
System.out.println("子类无参构造");
}
public Student (String str) //这里是调用的口子,但为什么去调用父类型.要调用也
{ //应该调用父类的有参构造才对!!
System.out.println(str);
}
}
//主class
class Srmethod
{
public static void main(String args[])
{
Student objs2=new Student("子类带一个参数的构造方法");
}
}
public Student (String str) //这里是调用的口子,但为什么去调用父类型.要调用也
{ //应该调用父类的有参构造才对!!
System.out.println(str);
}
package shuren.ren;
//class Teacher
class Teacher
{
public Teacher (String str)
{
System.out.println(str);
}
}
//class Student
class Student extends Teacher
{
public Student()
{
System.out.println("子类无参构造");
}
public Student (String str) //这里是调用的口子,但为什么去调用父类型.要调用也
{ //应该调用父类的有参构造才对!!
System.out.println(str);
}
}
//主class
class Srmethod
{
public static void main(String args[])
{
Student objs2=new Student("子类带一个参数的构造方法");
}
}