Java upcasting and downcasting

Assignment Help JAVA Programming
Reference no: EM131602744

Copy the previous application to a new folder, open it in Netbeans and rename it to "PolymorphismExample"

2.1 Add abstract key word to People and Employee class

2.2 For each class, override the Display method. For different class, different information should be displayed.
For Student, display: This is student [firstname] [lastname]
For Employee, display: This is Employee [firstname] [lastname] with EmployeeID [EmployeeID]
For Faculty, display: This is Faculty [firstname] [lastname] with EmployeeID [EmployeeID]
For Staff, display: This is Staff [firstname] [lastname] with EmployeeID [EmployeeID]

2.3 After you have built a Hierarchy of inherited classes, in you main application, please do following:
A. Create a new People object, with all 4 parameters
B. Create a new Student object, with 2 parameters
C. Create a new Faculty object, with all 6 parameters
D. Create a new Staff object, with all 6 parameters
E. Call all previous 4 objects' Display() function

2.4 Add a new java Interface "Training". In this Interface, you should have a method call "EmployeeTrain()". Make Employee class implements this Interface. Then add this method to subclass of Employee. In Faculty class, EmployeeTrain method will print "Faculty is trained.". In Staff class, EmployeeTrain method will print "Staff is trained." Now in your application, please call your Faculty and Staff objects' EmployeeTrain method.

2.5 Java upcasting and downcasting:

2.5.1 Upcasting: Java permits an object of a subclass type to be treated as an object of any superclass type. This is called upcasting.
Please upcasting a Faculty object to an Employee object, and call its Display function.

Then in your system.out.println, explain which Display method is called, Faculty.Display? or Employee.Display? or People.Display? Why?

2.5.2 Downcasting: Java permits an object of a superclass type to be treated as an object of any subclass type. This is called downcasting.
Please :
1. Upcasting a Faculty object to an Employee object,
2. Then downcasting this Employee object to Faculty object
3. Then call its Display function.
Then in your system.out.println, explain which Display method is called, Faculty.Display? or Employee.Display? or People.Display? Why?

Attachment:- Previous Application.zip

Reference no: EM131602744

Questions Cloud

Get these lines of code to loop forever : Get these lines of code to loop forever?
Define informal education in the field of death : Explain the difference between formal and informal education in the field of death
Which conflict with what the offeror stated : If an offeree attempts to add different terms in an acceptance, which conflict with what the offeror stated? Which of the following is true?
What do all abused substances have in common : What do all abused substances have in common. What are some inherited factors that might lead to an increased vulnerability to substance abuse
Java upcasting and downcasting : Add a new java Interface "Training". In this Interface, you should have a method call "EmployeeTrain()". Make Employee class implements
Distort trade patterns and lead to inefficiencies : How do subsidies distort trade patterns and lead to inefficiencies?
Discuss youth victimization : Discuss Youth Victimization, discuss the strengths and weaknesses of this study
Is foreign aid worsening our budget deficit : Is America obligated to help poor countries? Is foreign aid worsening our budget deficit?
Define properties of the local linearization : Someone claims that the square root of 1.1 is about 1.05. Without using a calculator, do you think that this estimate is about right?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd