I understand:
- Since Abstract class are nothing on its own i.e. vehicle that's why we want to create an object of an concrete implementation like Car,Bike etc.
Constructor of an Abstract class gets called during object chaining.
We can never directly create an object of Abstract class even if it contains a Constructor and all methods are implemented
why ? I am looking to understand from Compiler perspective, why Java forces these ?
Thanks
This is not a technical limitation, rather (as you have pointed out) a logical one. Java (and many other languages) enforce various rules not because they are impossible to break, but because this is an intentional part of the language.
What I understand that Abstract classes may contain abstract (empty without implementation) methods. If we instantiate an object and call the empty method, It's not going to work and may cause problem, hence compiler forces this RULE. any further in-sighter ?
You can't instantiate abstract class because it's just to give a structure your class which is extending it.
And if you want to initiate your class, then why you want to define it as abstract?