Apex Class| Rectangle
public virtual class Rectangle {
public virtual void area() {
System.debug('The area of a rectangle is the product of its length and width');
}
}
Apex Class| Square
public class Square extends Rectangle {
public override void area() {
System.debug('The area of a square is the product of its base with itself');
}
}
Apex Code
Rectangle obj1 = new Rectangle();
obj1.area();
Rectangle obj2 = new Square();
obj2.area();
Execution Log
Considerations
This cannot be referenced in a static context
Video
Video does not exists.