Creating a Subclass "Manager" in PL/SQL Inheriting from "Employee" Class
PL/SQL OOP: Exercise-4 with Solution
Write a PL/SQL code to create a "Manager" subclass inheriting from the "Employee" class, and add an attribute to store the number of employees managed.
A subclasses "Manager" subclass that inherits from the "Employee" class and add an additional attribute to store the number of employees managed by the manager.
Sample Solution:
PL/SQL Code:
Create the body of the "Employee" class
PL/SQL Code:
Create the "Manager" class with additional attribute and method
PL/SQL Code:
Create the body of the "Manager" class
PL/SQL Code:
To get the result for this code, createsan instances of both the "Employee" and "Manager" classes and call the calculate_bonus method for each of them.
PL/SQL Code:
Sample Output:
Statement processed. Employee Bonus: 11250 Statement processed. Manager Bonus: 15000
Flowchart:





Explanation:
In this example, the Employee class is subclassed by the Manager class. The Manager class, which implements specialized behavior while still inheriting the Employee class's functionality.
Previous: Method to calculate annual bonus based on salary in PL/SQL's "Employee" Class.
Next: Creating a "Shape" Class in PL/SQL with Area Calculation Method.
What is the difficulty level of this exercise?