Question

Java / Generic Programming When an iterator is created, what element will be removed if the...

Java / Generic Programming

When an iterator is created, what element will be removed if the "remove" method is called right away?

* The first one

* None-remove is not allowed to be called right way

* None-remove will throw a NoSuchElementException.

* The last one.

What is an advantages of using "enhanced for loops" rather than explicitly using iterators?

* It generates faster code.

* It can handle generic containers.

* It doesn't misbehave if the collection changes during the iteration.

* It provides a simple syntax for removing elements.

* It yields a simpler, clearer program.

Choose the correct statements about iterators from the following list (choose all that are correct):

In contrast to external iterators, internal iterators provide access to the current element

In contrast to external iterators, internal iterators are used in Java collections.           

In contrast to internal iterators, external iterators are their own object.     

In contrast to external iterators, internal iterators use methods of the collection to move.  

In contrast to internal iterators, external iterators permit multiple iterations to happen simultaneously.

In contrast to internal iterators, external iterators are easier to program.

What is the purpose of the Cloneable interface?

  • To tell Java that it is allowed to make a shallow copy of the object.
  • To give an ordering of instances.
  • To ensure that copies of the instances will be deep clones.
  • To say that instances can never be null
  • To declare that the class provides a public clone method.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

When an iterator is created, what element will be removed if the "remove" method is called right away?

Answer : The last one

What is an advantages of using "enhanced for loops" rather than explicitly using iterators?

Answer : It can handle generic containers.

Choose the correct statements about iterators from the following list (choose all that are correct):

Answer :

In contrast to external iterators, internal iterators are used in Java collections.    

In contrast to external iterators, internal iterators use methods of the collection to move.  

What is the purpose of the Cloneable interface?

Answer : To ensure that copies of the instances will be deep clones.

Add a comment
Know the answer?
Add Answer to:
Java / Generic Programming When an iterator is created, what element will be removed if the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Array with Iterator. Java style Implement an array data structure as a class JstyArray<E> to support...

    Array with Iterator. Java style Implement an array data structure as a class JstyArray<E> to support the Iterable interface such that the following code works: JstyArray<Integer> data; data = new JstyArray<Integer>(10); for (int i = 0; i < 10; ++i) { data.set(i, new Integer(i) ); } int sum = 0; for ( int v : data ) { if (v == null) continue; // empty cell sum += v; } The iterator provided by this class follows the behaviour of...

  • Please code this in java: The purpose of this assignment is to: Read double data in...

    Please code this in java: The purpose of this assignment is to: Read double data in to a TreeSet where each datum inserted is Math.abs(datum) (i.e., no negative values are inserted). NOTE: This will (i) sort the data placed into the TreeSet, and, (ii) remove duplicate values since no duplicates are allowed (i.e., duplicates will not be inserted). Create a list iterator. Iterate backwards through the TreeSet (i.e., from the largest value to the smallest) outputting all elements * -1.0....

  • This is for a java lab, in class instruction we are not allowed to use "this"....

    This is for a java lab, in class instruction we are not allowed to use "this". if anyone can help, and explain the importance of "this" and as to why we should or should not use it. Thank you in advanced. Intarraybag.java: public class IntArrayBag implements Cloneable { // instance variables private int[ ] data; private int manyItems; // constructor : behavior #1 public IntArrayBag( ) { final int INITIAL_CAPACITY = 10; manyItems = 0; data = new int[INITIAL_CAPACITY]; }...

  • Question from Object-Oriented Data Structures Using Java 4th Edition Chapter 5 Question 30 Add the following...

    Question from Object-Oriented Data Structures Using Java 4th Edition Chapter 5 Question 30 Add the following methods to the LinkedCollection class, and create a test driver for each to show that they work correctly. Code each of these methods by accessing the internal variables of the LinkedCollection, not by calling the previously defined methods of the class.String toString() creates and returns a string that correctly represents the current collection. 1. Such a method could prove useful for testing and debugging...

  • This task involves constructing a Java program that supports interaction via a graphical user interface.The object...

    This task involves constructing a Java program that supports interaction via a graphical user interface.The object is to implement a Scrabble graphical game. The basis for the game is quite simple. Presented with a 6x6 grid of Scrabble tiles, the challenge is for the player(s) to form as many high scoring words as possible.  Words may only be formed from sequences of adjacent tiles.  Two tiles are adjacent if their edges or corners meet.  A tile may...

  • JAVA 3 PLEASE ANSWER AS MANY QUESTIONS AS POSSIBLE! ONLY 2 QUESTIONS LEFT THIS MONTH!!! Question...

    JAVA 3 PLEASE ANSWER AS MANY QUESTIONS AS POSSIBLE! ONLY 2 QUESTIONS LEFT THIS MONTH!!! Question 12 pts Which is a valid constructor for Thread? Thread ( Runnable r, int priority ); Thread ( Runnable r, String name ); Thread ( int priority ); Thread ( Runnable r, ThreadGroup g ); Flag this Question Question 22 pts What method in the Thread class is responsible for pausing a thread for a specific amount of milliseconds? pause(). sleep(). hang(). kill(). Flag...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT