Professional Documents
Culture Documents
Inheritance 8: Object Oriented Programming in Java 1
Inheritance 8: Object Oriented Programming in Java 1
Inheritance 8: Object Oriented Programming in Java 1
System.out.println(c1);
In this example, after we finish with c1 and c2 objects, we set them to null
to indicate that they are no longer needed and then ask that the system’s
garbage collector be called with the call System.gc(). Java guarantees
that before the garbage collector runs to reclaim the space for each
object, the finalize method for each object is called but it does not
guarantee the order in which objects will be garbage collected.
import java.util.Date;
public class ManagerTest
{
public static void main(String[] args)
{
Manager boss = new Manager("Carl Cracker",
75000, new Date(1987,12,15));
boss.setSecretaryName("Harry Hacker");
System.out.println(boss.Name());
Employee[] staff = new Employee[3];
staff[0] = boss;
staff[1] = new Employee("Harry Hacker", 35000,
new Date(1989,10,1));
staff[2] = new Employee("Tony Tester", 38000,
new Date(1990,3,15));