Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

} Given below are the definition of class Person and Employee. public class Person ( private String name: public Person (String name) { this.name

image text in transcribed image text in transcribed 

} Given below are the definition of class Person and Employee. public class Person ( private String name: public Person (String name) { this.name name; ) ) public String getName () { return name: 1 public class Employee extends Person private int id: } public void display() () public Employee (String n, int i) { super (n); id - 1/ } public void display() ( System.out.println("Name= " +getName()+", ID="id); public void display (char c) ( System.out.println(c+" Name="getName()+" ID="id""+c); Based on the above class definitions, the following variables are declared: Person p: Employee e Answer all of the following questions: a) Write a Java statement that demonstrates the concept of polymorphic reference. (2 marks) b) Write a Java statement that demonstrates the concept of polymorphic behaviour. (2 marks) c) Which method demonstrates the concept of method overriding in the Employee class? (1 mark) d) Which method demonstrates the concept of method overloading in the Employee class? (1 mark) e) Suppose that one of the two classes is to be defined as abstract class. Which class and which method in the class are the most suitable to be defined as abstract? (2 marks)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

a An example of polymorphic reference in Java is Person p new EmployeeJohn 1234 Here the reference v... 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_2

Step: 3

blur-text-image_3

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

Elements Of Chemical Reaction Engineering

Authors: H. Fogler

6th Edition

013548622X, 978-0135486221

More Books

Students also viewed these Programming questions

Question

How much is 1/2 % of $10?

Answered: 1 week ago

Question

1301/2 % of $455 is what amount?

Answered: 1 week ago