How to pass parameterized objects to a function as argument

In reply to kartavya:

The above code worked even without casting.Thanks