Question: Given Queue<? super InputStreamReader> queue = new PriorityQueue<Reader>(), what are the following code compiles?
Choice:
A. queue.add(new Object());
B. queue.add(new InputStreamReader());
C. queue.add(new Reader());
D. queue.add(new FileInputStream());
E. queue.add(new ObjectInputStream());
F. queue.add(new BufferedReader());
G. queue.add(new FileReader());
H. queue.add(new BufferedInputStream());
Explain: regardless of the right side assignment, only the left side type declaration counts: Queue<? super InputStreamReader> queue You can only add the subclass of InputStreamReader to the queue. Of course you need to be familiar with NIO classes.