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 void testMethod(T input)

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 void testMethod(T input)
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)

class Stack {

/*

*/

}

d)

class Stack {

/*

*/

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!