Question: Consider the following code snippet: public static void print(E[] a) { for (int i = 0; i < a.length; i++) { System.out.println(a[i] + );
Consider the following code snippet:
public staticvoid print(E[] a) { for (int i = 0; i < a.length; i++) { System.out.println(a[i] + " "); } } int[] a = {3,6,5,7,8,9,2,3}; print(makeArray(a));
Assume that the method call to print(makeArray(a)) works correctly by printing the int array a. Which of the following headers for the makeArray method will make this possible?
I public static Integer[] makeArray(int[] a)
II public static E[] makeArray(int[] a)
III public static Integer[] makeArray(E[] a)
| I and III only |
| I only |
| I and II only |
| II and III only |
What does it mean when the syntax ? extends D is used?
| Any subclass of D may be used. |
| Any superclass of D may be used. |
| Any subclass or superclass of D may be used. |
| This indicates a wildcard with an upper bound. |
Consider the following code snippet that declares the GraduateStudent class:
public GraduateStudent extends Student { . . .} Which of these statements are false?
I GraduateStudent is a subclass of Student
II Stack
III Stack
| II only |
| III only |
| II and III only |
| I only |
Which of the following necessitates the type erasure process?
I The Java virtual machine does not work with generic types
II To maintain backward compatibility to older versions of Java
III Generics do not work with primitives
| I only |
| I and II only |
| II only |
| I and III only
Which of the following are restrictions of Java generic programming? I You cannot use the assignment operator = to assign one generic object to another. II You cannot use the == operator to compare two generic objects. III You cannot construct arrays of generic types.
|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
