Question: Java 1) Suppose the following methods are implemented in class TestClass: static void testMethod(T input) static void testMethod(String input) static void testMethod(char input) Which will
Java
1) Suppose the following methods are implemented in class TestClass:
static
static void testMethod(String input)
static void testMethod(char input)
Which will be called when the following statement is executed:
TestClass.testMethod("test");
| a) | static |
| b) | static void testMethod(char input) |
| c) | Nothing - this will throw an exception |
| d) | static void testMethod(String input) |
2) Which of the following are advantages of using generic methods/classes? Select all that apply!
| a) | Generics ensure methods and classes to look more alike |
| b) | Generics allow for algorithms that work on collections of different types |
| c) | Generics eliminate the need for many type casts |
| d) | Generics speed up all searches/sorts |
3) Which of the following is an appropriate class declaration for a generic class Stack?
| a) | class Stack /* */ } |
| b) | class Stack uses E { /* */ } |
| c) | /* */ } |
| d) | class /* */ } |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
