Inheritance using Generics
GENERIC CLASS EXTENDING ANOTHER GENERIC CLASS :


A type argument must be passed to the type parameter of a base class. You can do so while extending the base class or while instantiating the derived class.
Examples :
1)
2)

3)
4)
5)
NON-GENERIC CLASS EXTENDING A GENERIC CLASS
You can extend a generic base class to define a nongeneric base class. To do so, the derived class doesn’t define any type parameters but passes arguments to all type parameters of its generic base class. For example
In the preceding example, NonGenericPhoneParcel is a nongeneric class that passes argument Phone to its base class Parcel.
Last updated
Was this helpful?