The complicated relationship between inheritance and generics

The following code explains how an object sent as a parameter is used to access the variable in another class.

code

1)accessing variables using generics and inheritance

here when IELTS class is sent as an object to cake class that has a type parameter T that extends gre class(restricted generics), the ielts class has only access to the variables of gre class. But here, the gre class extends jinnu class so, we are able access the variables of gre and jinu class.

Using inheritance, it is easy to access variables of another class. On the other hand, a combination of generics and inheritance to access a variable of another class is too complicated.

--

--