Java OOP - Generic Methods - Q3, Q4, and Q5

preview_player
Показать описание
A recording of me working on some basic / introductory tutorial questions on Generic Methods: Q3, Q4, and Q5 (questions below). Overloading and User Defined Exceptions are also discussed.

Q3. Write a generic method, namely printArray, to print the contents of an array. Write a tester class that uses the printArray method to print the contents of an array of Integers; array of Doubles; array of Characters; and array of Strings.

Q4. Overload the generic method printArray, created for the above question 3, so that it takes two additional integer arguments, from and to. A call to this method prints only the designated portion of the array [Elements of the array between from and to index (inclusive of both from and to)].

Note: You need to validate from and to. If either is out of range, the overloaded printArray method should throw an InvalidSubscriptException; otherwise, printArray should print the elements accordingly.

Q5. Create a tester class to test the overloaded generic method printArray.

Moose's Software Valley - Established July, 1996.
Рекомендации по теме
Комментарии
Автор

You sounded super motivated, that got me motivated! Nicely explained!

Meewbs