Lets say I have an abtract class called MedicalFacility with the following abtract method:
public abstract class MedicalFacility
public abstract boolean visit(Patient p);
Bellow is a method that belong to a class that does not extend from the abstract class MedicalFacility. But within this method it invoked the visit method that is in the subclass (Hospital or HealthClinic) of the abstract class (MedicalFacility).
public boolean present(MedicalFacility m)
if(m instanceof Hospital)
When do we exactly use ((Hospital)m).visit(this) or m.visit(this)? What are their differences?.
Your help is kindly appreciated.