Solved

Determine the Output of the MyLinkedList Generic Class Code Below

Question 54

Multiple Choice

Determine the output of the MyLinkedList generic class code below when the main method executes.
Public class MyLinkedList<E>
{
Private MyNode first;
Public MyLinkedList(E


A) List first element = Hello
B) List first element = null
C) compiler error is generated by first = new MyNode() ;
D) no output
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<String> list = new MyLinkedList<String>("Hello") ;
System.out.println("List first element = " + list.getFirst() ) ;
}
}

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions