Services
Discover
Homeschooling
Ask a Question
Log in
Sign up
Filters
Done
Question type:
Essay
Multiple Choice
Short Answer
True False
Matching
Topic
Computing
Study Set
Big Java Late Objects
Quiz 18: Generic Classes
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Practice Exam
Learn
Question 61
Multiple Choice
Consider the following code snippet: Public static <T> void fun(T[] t) { . . . } Erasure by the compiler of method fun will generate which result?
Question 62
Multiple Choice
Erasure of types limits Java code somewhat with generics. Which of the following are limitations of generic code? I cannot instantiate a type variable II cannot return a type variable III cannot pass a type variable
Question 63
Multiple Choice
Generics limit Java code somewhat. Which of the following are limitations of generic code? I cannot declare static variables of a generic type II cannot declare static methods of a generic type III cannot declare static inner classes of a generic type
Question 64
Multiple Choice
Consider the following code snippet: Public class LinkedList<E> { Private E defaultValue; Public static List<E> replicate(E value, int n) { . . . } Private class Node { public String data; public Node next;) ) . . } What is wrong with this code?
Question 65
Multiple Choice
Consider the following code snippet: Public static <E extends Measurable> E min(E[] objects) Which of the following represents the result of type erasure on this code?
Question 66
Multiple Choice
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
Question 67
Multiple Choice
What is the result when a program constructs a generic class without passing a type variable, as in the following code? Stack stack = new Stack() ; I the program will compile and run II the compiler will issue an error III the compiler will issue a warning
Question 68
Multiple Choice
Given the following declaration, what is the type parameter in Stack<E> replaced with? Private Stack<String> myStack = new Stack<String>() ;
Question 69
Multiple Choice
To maintain compatibility with pre-generic Java, type parameters are replaced by ordinary types called ____.
Question 70
Multiple Choice
Consider the following code snippet: Public class LinkedList<E> { Private E defaultValue; //Line 1 Public void add(E value, int n) { . . . } //Line 2 Private static class Node { public E data; public Node next;) //Line 3 ) . . } What is wrong with this code?
Question 71
Multiple Choice
Given the following declaration, what is the type parameter in Stack<E> replaced with? Private Stack myStack = new Stack() ;
Question 72
Multiple Choice
Suppose a generic method accepts a generic unconstrained argument p. What restrictions are placed on p by the compiler?
Question 73
Multiple Choice
If a class requires two generic type variables, how many can you legally provide in Java? I 0 II 1 III 2
Question 74
Multiple Choice
Consider the following code snippet: Public interface MyInterface<E> { . . . } Public interface YourInterface<E, T> extends MyInterface<E> { . . . } Which of these are legal class declarations? I public class SomeClass implements YourInterface<String, Double> { . . . } II public class SomeClass implements YourInterface { . . . } III public class SomeClass implements YourInterface<String> { . . . }
Question 75
Multiple Choice
Generics limit Java code somewhat. Which of the following are considered limitations of generic code? I cannot have an array of a generic type II cannot have primitive type variables III cannot construct an object of a generic type