Why is the following code returning an illegal assignment error in anonymous window?
Line: 3, Column: 9 illegal assignment from truck to vehicle
Super Class
public virtual class vehicle {
public void model(){
system.debug ('Model method of vehicle class ');
}
public void speed(){
system.debug('Speed of the vehicle depends of the model');
}
}
Child Class
public class truck extends vehicle
{
public override void speed()
{
system.debug('Truck has speed of 20 mile/hr');
}
}
Execute Anonymous Script
vehicle v=new vehicle();
v.speed();
vehicle v2=new truck();
v2.speed();
v2.model();