Answered step by step
Verified Expert Solution
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
} 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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started