Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago