Question: JAVA Polymorphism is the ability for objects to have many different forms which helps to provide a more manageable code. Based on the following cases,

JAVA
JAVA Polymorphism is the ability for objects to have many different forms

Polymorphism is the ability for objects to have many different forms which helps to provide a more manageable code. Based on the following cases, provide the solution using the concept of polymorphism: (a) A Lecturer and a Tutor is an Employee of a university. All Employee objects will have a fixed salary and on top of that, a Lecturer will have additional fixed allowance allocated, while a Tutor will have an overtime claim of RM20 per hour. Define all these THREE (3) classes and provide the methods to calculate the monthly income for Lecturer and Tutor. Define a static method in Employee class to calculate the total income paid to all employees. (15 marks) (b) Since all classes in Java inherit from the class Object, rewrite the code segment in Figure 1 below to take advantage of the concept of polymorphism. Declare all these GUI components as an array of Object and use a loop to call the appropriate methods based on the actual object form. JPanel pl = new JPanel(); JTextField tft - new JTextField(5) JButton bl-new JButton ("OK"); JButton b2 - new JButton ("CANCEL"); pl.setBackground (Color.YELLOW); til.setBackground (Color.YELLOW); bl.netBackground (Color.YELLOW) b2.setBackground (Color.YELLOW): String temp = tf.getText: bl.addActionListener(this) b2.addActionListener(this) Finn 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!