Read the previous post.

So lets move on to question number 5.

The question was “If you have a collection of Time elements what do you have to do to put SportsTime elements in it.

Of course the answer is nothing because we used inheritance we can have SportsTime elements in a Time collection. It’s called polymorphism and it’s one of the strong points of OOP.

Question number 6

I have a collection of Time which also contains SportsTime elements. I want to execute the method ToUniversalTime on it. Will I always get the same result. I yes elaborate and explain what you have to do to get the correct result. If No eleaborate.

Yes you will always get the same result for all the objects in that collection even the SportsTime ones. If you wan to get the SportsTime specific implementation you will have to cast the result to SportsTime. For example in C# this would be.

List<Time> times = new List<Time>(); Time time1 = new Time(12,12,12); Time time2 = new Time(12,12,12); SportsTime sportstime1 = new Time(12,12,12); times.Add(time1); times.Add(time2); times.Add(sportstime1); // To get the ToUnversalTime of Time do nothing Console.WriteLine(times(2).ToUniversalTime()); // To get the ToUniversalTime of SportsTime cast Console.WriteLine(((SportsTime)times(2)).ToUniversalTime());