About Question enthuware.ocpjp.v7.2.1292 :
Posted: Sun Sep 06, 2015 12:26 am
Why cant "Queue container = new PriorityQueue();" be used?
Java Certification Resources and Java Discussion Forum
https://enthuware.com/forum/
Since the return type of getRequestToProcess() method is Request, and the return statement does not have a cast, it means that container must be a typed generic collection that returns Request objects only.
Would it be correct? it would compile, but PriorityQueue would throw exception while adding an element to nonempty queue.Queue<Request> container = new PriorityQueue<Request>();