asiavoices
Programmer
Hello again all,
I have a question regarding how a method's result would look like if it was inherited down to 4 levels in a class hierarchy.
I understand that if you want to use a parent's method, you use a super.methodname(); but what if....
For example I have a base class called Person with a method called print() - just prints the common variables like name, address & phone number, etc..
Then I did this.... (each print() method in the subclasses has their own info to be printed).
Student extends Person
{
.....
print();
}
GradStudent extends Student
{
....
print();
....
}
PhdStudent extends GradStudent
{
.....
print();
.....
}
Am I correct that if I want to print all the "stuff" in the print methods in the above the hierarchy in the last one (PhdStudent) , this is what I have to do.
Person.print();
Student.print();
GradStudent.print();
Just wondering...
Thanks,
Christopher
I have a question regarding how a method's result would look like if it was inherited down to 4 levels in a class hierarchy.
I understand that if you want to use a parent's method, you use a super.methodname(); but what if....
For example I have a base class called Person with a method called print() - just prints the common variables like name, address & phone number, etc..
Then I did this.... (each print() method in the subclasses has their own info to be printed).
Student extends Person
{
.....
print();
}
GradStudent extends Student
{
....
print();
....
}
PhdStudent extends GradStudent
{
.....
print();
.....
}
Am I correct that if I want to print all the "stuff" in the print methods in the above the hierarchy in the last one (PhdStudent) , this is what I have to do.
Person.print();
Student.print();
GradStudent.print();
Just wondering...
Thanks,
Christopher