I'm new in OOP and I'm quite puzzled in casting. Please check the code and declaration below for your reference.
Then I declared this:
Person[] people = new Person[10];
people[0] = new Learner("John"); // what type of casting is this?
I'm new in OOP and I'm quite puzzled in casting. Please check the code and declaration below for your reference.
Then I declared this:
Person[] people = new Person[10];
people[0] = new Learner("John"); // what type of casting is this?
This is an upcast. You are saving into an object of Type „Person“ so you can’t Access The Elements of Type „Learner“. This was explained in this Post