0

Lets say i want to use methods of an abstract class, is there any way i can do it without overriding one of its methods ??

5th Jun 2017, 2:18 PM
Valeria Lopez Lizarraga
Valeria Lopez Lizarraga - avatar
2 Réponses
+ 3
You can do it from the sub class with the super keyword (or if it's protected just call it). Or if the sub class doesn't actually override anything, then sure just call the method with an object of the same type as the super class.
5th Jun 2017, 3:23 PM
Rrestoring faith
Rrestoring faith - avatar
+ 1
If the abstract class method was a public static method you should be able to invoke it without instantiation (and no subclass). For example: If MyAbstractClass had a public static method called methodA(), I can invoke it as: MyAbstractClass.methodA() No need to write a class that extends MyAbstractClass to get access to that method.
5th Jun 2017, 3:36 PM
Jason Runkle
Jason Runkle - avatar