So i have the abstract class Worker, which has the abstract function computePay.
The two children classes of this class are HourlyWorker and FixedWorker,
now i have provided the implementation of computePay in both these classes.Now my code says
Worker[] w=new worker[2];
w[0]=new HourlyWorker;
w[1]=new FixedWorker;
now when i say w[0].computePay how am i sure that which computePay is called,
i know the one from the child class will be called, but which one?
i.e.
If my both the child classes have different implementation of the computePay function,
will the following code give me the desired result?
w[0].computePay //Prints the pay as per the implementation in HourlyWorker;
w[1].computePay //Prints the pay as per the implementation in FixedWorker;
Also i heard about the instance of operator/keyword, but i dont know will it be of any use here?
printlnstatements for debugging.