class Test { static void getAreaTest(Rectangle r) { int width = r.getWidth(); r.setHeight(10); System.out.println("Expected area of " + (width * 10) + ", got " + r.getArea()); } public static void main(String[] args) { Rectangle rc = new Rectangle(2, 3); getAreaTest(rc); Rectangle sq = new Square(); sq.setWidth(5); getAreaTest(sq); } }- The code is loosely coupled and avoids unnecessary entanglements. Without LSP, when a subclass cannot substitue its parent class, we have to write multiple if-else statements to determine the class or the type to handle certain cases differently. Changes should be applied in many places - Violtion - Square inheriting from a Rectanglepublic class MotorCar implements Car { private Engine engine; //Constructors, getters + setters public void turnOnEngine() { //turn on the engine! engine.on(); } public void accelerate() { //move forward! engine.powerOn(1000); } } Copy