Java Virtual Repride
//Every non-static method in Java is a virtual function except for final and private methods.
//The methods that cannot be used for the polymorphism is not considered as a virtual function.
//Java does not have a virtual keyword like C++,
class Vehicle{
void make(){
System.out.println("heavy duty");
}
}
public class Trucks extends Vehicle{
void make(){
System.out.println("Transport vehicle for heavy duty");
}
public static void main(String args[]){
Vehicle ob1 = new Trucks();
ob1.make();
}
}
//Output: Transport vehicle for heavy duty
LOGNST