Page 150 - CTS - CSA TP - Volume 2
        P. 150
     COMPUTER SOFTWARE APPLICATION - CITS
           TASK 2: Employee and Manager Classes:
                // Superclass
              class Employee {
                  String name;
                  double salary;
                  // Constructor
                  Employee(String name, double salary) {
                      this.name = name;
                      this.salary = salary;
                  }
                  void displayDetails() {
                      System.out.println(“Name: “ + name);
                      System.out.println(“Salary: $” + salary);
                  }
              }
              // Subclass
              class Manager extends Employee {
                  String department;
                  // Constructor
                  Manager(String name, double salary, String department) {
                      super(name, salary); // Call superclass constructor
                      this.department = department;
                  }
                  @Override
                  void displayDetails() {
                      super.displayDetails(); // Call superclass method
                      System.out.println(“Department: “ + department);
               }
           }
           // Main class
           public class EmployeeDemo {
               public static void main(String[] args) {
                                                           135
 CITS : IT & ITES - Computer Software Application - Exercise 100  CITS : IT & ITES - Computer Software Application - Exercise 100





