28/01/25 ----------- Q)What is the syntax to create a child class(sub class) in Java? class extends { } For eg. class Car extends Vehicle{ }//sub class DIAGRAM Q)How to create is-a relationship between two classes in Java? =>by using the keyword "extends". Q)What is the output of the following program? class Vehicle{ void move(){ System.out.println("Vehicle is moving"); } } class Car{ } class InheritanceApplication{ public static void main(String args[]) { Car c=new Car(); c.move(); } } Ans:- The above program causes compilation error. Reason:- move() method is not defined in Car class. Nor it is made the child of Vehicle class. Q)What is the output of the following program? //InheritanceApplication.java class Vehicle{ void move() { System.out.println("Vehicle is moving"); } }//super class class Car extends Vehicle{ }//sub class class InheritanceApplication{ public static void main(String args[]) { Car c=new Car(); c.move(); } } Ans:- Vehicle is moving