Welcome! Log In Create A New Profile

Advanced

Implemtation of another class

Posted by Jackes 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Implemtation of another class
October 21, 2010 07:18PM
public class PostGraduateStudent extends Student{

String researchGroup;
PostGraduate(String fn, String ln, Gender g, int nomr, String rg){
super(fn,ln,g,nomr);
researchGroup = rg;
}
public String toString(){
return super.toString() + "," + researchGroup;
}
}

public class Student{

enum Gender{MALE, FEMALE}
//{
String firstName;
String lastName;
Gender gender;
int noOfModulesRegistered;
//}
static double costOfModule = 756.90;

Student(String fn, String ln, Gender g, int nomr){
firstName = fn;
lastName = ln;
gender = g;
noOfModulesRegistered = nomr;
}

When another class is implemented like the example above, can the parameter names differ from the parametrize constructor in the Student class and the parametrize constructor of the PostGraduateStudent Class? Or must the parameter names be the same?

In the PostGraduateStudent what does the word super means? What is the purpose of the word?
Re: Implemtation of another class
October 23, 2010 12:06PM
Yes, the names may differ but not their sequence.
The word super is used to call the constructor of extended class, student in this case. It is the correct way of calling a constructor inside another constructor. You can see
super(fn,ln,g,nomr); as student(fn,ln,g,nomr);
Sorry, only registered users may post in this forum.

Click here to login