In the below code what exactly is the function of instanceof operator? I understand that if block executes only if its true i.e (obj instanceof MountainBike==true).Assuming its true why does we should again typecast (MountainBike)obj?
if (obj instanceof MountainBike) {
MountainBike myBike = (MountainBike)obj;
}