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

  Design a single class that expresses the commonality

Design a single class that expresses the commonality of these concepts.

  Write program that will maintain the registration of college

Write a (Java) program that will maintain the registration of a (very small, for this project) college, using the Student, Course, and Sorted Array classes that you have already written.

  Complete the loops to print the harshad numbers

Complete the loops to print the Harshad numbers in the range of 1 to 1000 - public class Harshad

  1 explain the differences between our specifications of the

1. explain the differences between our specifications of the sorted list adt and the binary search tree adt.2. define a

  Design java application that will read file containing data

Design a Java application that will read a file containing data related to the US. Crime statistics from 1994-2013 - What year was the Murder rate the highest

  Constructing a simple flowchart that describes simple logic

Constructing a simple flowchart that describes simple logic flow through a program. Translating the flowchart into pseudo code. Creating a simple module, based on the pseudo code created in step 2, which accepts a parameter and returns a value.

  Design and implement a java program that will gather info

Design and implement a Java program that will gather a user's first name, middle initial, lastname, age in years, and 3 lucky numbers. The program should output the following based on the user's input

  Write a java program that simulates a small cpu vm

Design and implement a program to simulate the operation of the SIMMAC based - dumps the contents of all registers and memory and then prints an "End of Job" message.

  Write a method that returns the last digit of an integer

Write a method named lastDigit that returns the last digit of an integer - It should work for negative numbers as well.

  How would you categorize this kind of script what resources

write a 200- to 300-word short-answer response to the following bull how would you classify this type of script? bull

  The program should ask the user to enter the student'' answer

Your program should store these correct answers in an array. (Store each question's correct answer in an element of a string array.) the program should ask the user to enter the student's answers for each of the 20 questions, which should be stored i..

  Write method that accepts an array of integers as a paramete

Write a method that accepts an array of integers as a parameter and returnsa referenceto an array that contains the even numbers in the array original array.

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