Question: MC question about programming (java language) Consider the following class: class Greeter { String name; public void sayHello() { System.out.println(Hello + name); } Select the

MC question about programming (java language)
MC question about programming (java language) Consider the following class: class Greeter
\{ String name; public void sayHello() \{ System.out.println("Hello" + name); \} Select
the correct statement about generics in the following method declaration public static
void foo( T a a. sayHello(); \} Select one: a. T can
be instantiated with any class b. Tcan be instantiated with any subclass

Consider the following class: class Greeter \{ String name; public void sayHello() \{ System.out.println("Hello" + name); \} Select the correct statement about generics in the following method declaration public static void foo( T a a. sayHello(); \} Select one: a. T can be instantiated with any class b. Tcan be instantiated with any subclass of Greeter c. the body of the method is incorrect, as T may not have a method Consider the following code public static void add(int a, int b) \{ return a+b; \} public static void add(String a, String b) \{ return a+b; \} This is an example of... Select one: a. Ad-hoc polymorphism b. Parametric polymorphism Marked out of 1.00 P Flag question Consider the following generic data type: class TreeNode { public T payload; public TreeNode left; public TreeNode right; public TreNode(T o) \{ payload = o; left = null; right = null; \} Is the following code correct? TreeNode> tree = new TreeNode (new Integer (4)); tree. left = new TreeNode> ("Five"); tree. right = new TreeNode> (new Integer (6)); Select one: a. no, because must be of type b. yes c. no, because must be of type Question 4 Not yet answered Marked out of 1.00 Flag question When is it preferable to use LinkedList vs ArrayList? When we need to perform many removal operations When we need to access elements at specific positions When we need to perform many insertion hich ones of the following for-each loops are allowed in Java? elect one or more: a. String[] strArray ={ "Hello", "world", "!" }; for (String s: strArray ){ I/ Get each element of strArray System.out.println(s); \} b. LinkedList intList =... If Creote list of integers for (Integer i: intList) { Get each element of intList System.out.println(i); \} c. String myStr = "Hello world!"; for (char c: mystr ) // Get each character of mystr System,out.println(c); \}

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!