October 1st, 2013, 03:59 PM
I have an abstract Employee class as shown below.
if I create the below statement, it will work.
public abstract class Employee
public abstract double earnings();
But the below statement will not work due to Employee is abstract. It cannot be instantitated.
Employee employees = new Employee;
Why does it work for the employees array but not work for the employee object? Is an array the same an object?
Employee employee = new Employee();
Last edited by soap; October 1st, 2013 at 04:01 PM.
October 1st, 2013, 04:20 PM
What you are creating is an array of references to Employee objects. Initially each reference will be null.
In order to instantiate an element, you would have to subclass Employee so that the subclass is not abstract and create an instance of that subclass.
October 1st, 2013, 04:24 PM