boolean hasMoreElements( ) return true while there are still more elements to extract - Wrapper classes

Q.  Which method when implemented must return true while there are still more elements to extract, and false when all the elements have been enumerated?

- Published on 19 Oct 15

a. Object nextElement( )
b. boolean hasMoreElements( )
c. Both A & B
d. None of the above

ANSWER: boolean hasMoreElements( )
 

    Discussion

  • Nirja Shah   -Posted on 15 Dec 15
    The methods declared by Enumeration are summarized in the following table:

    boolean hasMoreElements()
    - When implemented, it must return true while there are still more elements to extract, and false when all the elements have to be enumerated.

    Object nextElement()
    - This returns the next object in the enumeration as a generic Object reference.

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)