READ Free Dumps For Oracle- 1z0-804
Question ID 21447 | Given the following code fragment:
public static void main(String[] args) {
Connection conn = null;
Deque<String> myDeque = new ArrayDeque<>();
myDeque.add("one");
myDeque.add("two");
myDeque.add("three");
System.out.println(myDeque.remove());
}
What is the result?
|
Option A | Three
|
Option B | One
|
Option C | Compilation fails
|
Option D | The program runs, but prints no outout
|
Correct Answer | B |
Explanation Explanation: add boolean add(E e) Inserts the specified element into the queue represented by this deque (in other words, at the tail of this deque) if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available. When using a capacityrestricted deque, it is generally preferable to use offer. This method is equivalent to addLast(E). remove E remove() Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque). This method differs from poll only in that it throws an exception if this deque is empty. This method is equivalent to removeFirst(). Returns: the head of the queue represented by this deque Class ArrayDeque
Question ID 21448 | Which concept allows generic collections to interoperate with java code that defines collections that use raw
types?
|
Option A | bytecode manipulation
|
Option B | casting
|
Option C | autoboxing
|
Option D | auto-unboxing
|
Option E | type erasure
|
Correct Answer | E |
Explanation Explanation: The type erasure of its leftmost bound, or type Object if no bound was specified. examples: type parameters type erasure List
List Map.Entry Map.Entry > Cloneable > Object T[] toArray(T[] a) Object[] toArray(Object[] a) The type erasure process can be imagined as a translation from generic Java source code back into regular Java code. In reality the compiler is more efficient and translates directly to Java byte code. But the byte code created is equivalent to the non-generic Java code.