Question: Consider the following declaration: LinkedList list = new LinkedList (); This declaration implies that the LinkedList class could begin with which of the following code
Consider the following declaration:
LinkedList list = new LinkedList<>();
This declaration implies that the LinkedList class could begin with which of the following code statements?
I public class LinkedList { . . . }
II public class LinkedList { . . . }
III public class LinkedList { . . . }
Which of the following satisfies the wildcard ? extends Component?
Determine the output of the MyLinkedList generic class code below when the main method executes.
public class MyLinkedList { private MyNode first; public MyLinkedList(E e) { first = new MyNode(); first.data = e; first.next = null; } public E getFirst() { return first.data; } private class MyNode { private E data; private MyNode next; } public static void main(String[] args) { MyLinkedList list = new MyLinkedList<>("Hello"); System.out.println("List first element = " + list.getFirst()); } }
| | List first element = null |
| | List first element = Hello |
| | compiler error is generated by first = new MyNode(); |
Which of the following satisfies the wildcard ? extends Object?
I String
II JComponent
III Scanner
Consider the following class declaration:
public class SavingsAccount extends BankAccount { . . . } Which of the following statements about these classes is correct?
| | There is no relationship between ArrayList and ArrayList |
| | ArrayList is a subclass of ArrayList. |
| | ArrayList is a subclass of ArrayList. |
| | ArrayList extends ArrayList. |