Posts

Showing posts with the label java

OH MY.. Why We Use Extends In Java

Image
The final keyword is much more related to the intent behind that class than any physical restriction from Java or the JVM. If you ever had to use an undocumented API you know exactly why. Inheritance In Java Geeksforgeeks Class Add static int addMethod int a int b return a b. Why we use extends in java . We shouldnt need to talk about this best practice but I have seen way too many custom exceptions without any Javadoc. It is a keyword that indicates the parent class that a subclass is inheriting. Its a general best practice to document all classes fields constructors and methods of your API. Abstraction is an important concept of object-oriented programming that allows us to hide unnecessary details and only show the needed information. Undocumented APIs are very difficult to use. So basically extends keyword is used to extend the functionality of the parent class to the subclass. It specifies the super class in a class declaration using extends keyword. The exte...