DATABASE FUNDAMENTALS
BASICS OF BIG DATA
|
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
What will be the output of the following Java program? import java.util.*; class Collection ____ iterators { public static void main(String args[]) { LinkedList list = new LinkedList(); list.add(new Integer(2)); list.add(new Integer(8)); list.add(new Integer(5)); list.add(new Integer(1)); Iterator i = list.iterator(); Collections.reverse(list); while(i.hasNext()) System.out.print(i.next() + “ “); } }
|
|
2 8 5 1
|
|
|
1 5 8 2
|
|
|
2
|
|
|
2 1 8 5
|
Explanation:
Detailed explanation-1: -Explanation: The output of the Java compiler is bytecode, which leads to the security and portability of the Java code. It is a highly developed set of instructions that are designed to be executed by the Java runtime system known as Java Virtual Machine (JVM).
Detailed explanation-2: -Explanation: Iterators are STL components used to point a memory address of a container. They are used to iterate over container classes.
Detailed explanation-3: -Explanation: hasNext() returns boolean values true or false.
Detailed explanation-4: -begin(): The begin() function returns an iterator pointing to the first element of the container.
There is 1 question to complete.