In which lines the parameter T is not allowed to use (select 3 choices):
public class Test & lt; T & gt; {
     private T item; // (1)
     private static T [] storage = new T [100]; // (2)
     public Test (T item) {this.item = item; } // (3)
     public T getItem () {return item; } // (4)
     public void setItem (T newItem) {item = newItem; } // (5)
     public static void getAllItems (T newItem) {// (6)
         T temp; // (7)
Any use of the type-parameter in a static context is forbidden. Type parameter can NOT be used as:
- The type of static field (line 2);
- The type of the return value of the static method;
- The type of the formal parameter of the static method (line 6);
- The type of a local variable in the body of the static method (line 7);
- The type of a local variable in the static initialization block, etc.
In addition, the type parameter can not be used in the operator new, even when creating arrays (line 2).
Java Quiz
Start Quiz

or Read more about Java Quiz

Mobile Beta

Get it on Google Play