Call the method of base Class which was over ridden
- by Abhijith Venkata
I have illustrated my question in this example
class Car {
public void start(){
System.out.println("Car Started!!!");
}
}
class Mercedes extends Car {
public void start(){
System.out.println("Mercedes Started!!!");
}
}
Now, in my main program, I write
Mercedes m = new Mercedes();
m.start();
It prints: Mercedes Started!!!
How do I call the start() method of Car class using the same object so that the output can be
Car Started!!!.
Edit:
Actually It was asked in an interview I attended. I gave the super keyword answer. But the interviewer denied it. He said he'd give me a hint and said Virtual Function. I have no idea how to use that hint.