Answered step by step
Verified Expert Solution
Question
1 Approved Answer
public class Person { private String name; public Person (string name) i this.name = name; public string getName () i I return nane; public void
public class Person \{ private String name; public Person (string name) i this.name = name; public string getName () i I return nane; public void display() i ) public class Employee extends Person private int id: public Employee (String n, int i) 1 super (n)/ id=if 1 public void display () ( System. out.println ("Name= "+getName ()+", ID=" + Id); 1 public void display (char c) 1 System.out.println (c+" Name= " +getNane ()+",1D="+id+"+c)z 1 1 Based on the above class definitions, the following variables are declared: Person pi Employee er Answer all of the following questions: a) Write a Java statement that demonstrates the concept of polymorphic referenc (2 mark 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
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