Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Which one is NOT correct about the following piece of java code? public class SimpleCollection { public static void main ( String [ ] args

Which one is NOT correct about the following piece of java code?
public class SimpleCollection {
public static void main(String[] args){
Collection c;
c = new ArrayList();
System.out.println(c.getClass().getName());
for (int i=1; i <=10; i++){
c.add(i);
}
Iterator iter = c.iterator();
while (iter.hasNext())
System.out.println(iter.next());
}
}
Question 7 options:
The first elemet is printed in the while loop is 2 because the function hasNext() advances the iteratro
A double type element like 0.5 can be added to the collection c
iter is used to iterate over elements in the collection c
There are 10 elements in the collection c

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions