Question: please solve the java questions below and explain in details 1.1 Given that HourlyEmployee and SalariedEmployee are subclasses of FullTimeEmployee, suppose we have: FullTimeEmployee full


1.1 Given that HourlyEmployee and SalariedEmployee are subclasses of FullTimeEmployee, suppose we have: FullTimeEmployee full = new FullTimeEmployee(); HourlyEmployee hourly = new HourlyEmployee 0); SalariedEmployee salaried = new Salaried Employee (; full = salaried; Which one of the following assignments would be legal both at compile- time and at run-time? a. salaried = (SalariedEmployee) full; c. b. salaried = full; salaried = (Full TimeEmployee) full; d. hourly = (HourlyEmployee) full; Create a small project to validate your claim. 1.2 Assume that the classes below are all in the file Polymorphism.java. Determine the output when the project is run. Would the output be different if the call to printin were System.out.println (a.toString()? import java.util." public class Polymorphism { public static void main(String args[]) Scanner sc = new Scanner (System.in); A a; int code = sc.nextInt(); If (code == 0) a = new A0: // non-zero int entered a = new DO: else 1.2 Assume that the classes below are all in the file Polymorphism.java. Determine the output when the project is run. Would the output be different if the call to printin were System.out.printin (a.toString()? import java.util." public class Polymorphism public static void main(String args[ ( Scanner sc = new Scanner(System.in); Aa: int code = sc.nextinto: if (code = 0) a = new AO: else non-zero intentered a = new DO: Pape 56 System.out.println(a) method main }/class Polymorphism class A public String toString 0 return "A"; y method to String }//class A class D extends A public String toString 0 return "D": > method toString W class D 1.3 In the Employee class, modify the toString method so that the gross pay is printed with a comma to the left of the hundreds digit. For example, if the name is O'Brien, Theresa" and the gross pay is 74400.00, the toString method will return O'Brien, Theresa $74,400.00 1.4 What can you infer about the identifier out from the following message? System.out.printin ("Eurekal"); What is the complete declaration for the identifier out? Look in java.lang.System.java
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
