CDOP3203
CDOP3203
1. Inheritance
2. A "subclass" is created when it is derrived from "another class". The "class"
that it is derrived from is also known as "superclass". Its a hierarchy of objects
in which the "subclass" inherits from "superclass".
3. The correct method to access a private data from a different class is by
creating and using "getter" and "setter" methods. This is also called "accessor"
and "mutator" methods.
4. 5
5. "Method overriding" is an approach that replaces a relatively similar method
from the inherited class in a subclass. Usually, the "overriding method" have the
same name, number and types of parameter values, and return value type as the
inherited method.
Part B
1.
2.
public Person (String name, String address, String phone, String email) {
Name = name;
Address = address;
Phone = phone;
Email = email;
}
public Student () {
super();
StudentNo = "";
}
public Student (String name, String address, String phone, String email, int
studentno) {
super(name, address, phone, email);
StudentNo = studentno;
}
public Employee() {
super();
Salary = 0.00;
DepartmentId = 0;
}