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 Early Objects
Quiz 18: Generic Classes
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Practice Exam
Learn
Question 61
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
Question 62
Multiple Choice
Given the following declaration, what is the type parameter in Stack<E> replaced with? private Stack myStack = new Stack() ;
Question 63
Multiple Choice
Consider the following code snippet: public class LinkedList<E> { private E defaultValue; public void add(E value, int n) { ...} private static class Node { public E data; public Node next; } ... } What is wrong with this code?
Question 64
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 65
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 66
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 67
Multiple Choice
Given an array myArray, which of the following represents an expression to determine the type of the elements of the array?
Question 68
Multiple Choice
Suppose a generic method accepts a generic unconstrained argument p.What restrictions are placed on p by the compiler?
Question 69
Multiple Choice
Given an object myObject, which of the following represents the correct code to make a new instance of an object having the same class, assuming that the class has a constructor with no arguments?
Question 70
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