Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

image text in transcribed

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

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions