if you want to remove an article from website contact us from top.

    which of the following method is used to return a set that contains the entries in a map

    Mohammed

    Guys, does anyone know the answer?

    get which of the following method is used to return a set that contains the entries in a map from screen.

    Map (Java Platform SE 8 )

    SKIP NAVIGATION LINKS

    OVERVIEW PACKAGE CLASS USE TREE DEPRECATED INDEX HELP

    Java™ Platform

    Standard Ed. 8 PREV CLASS NEXT CLASS FRAMES NO FRAMES ALL CLASSES SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

    compact1, compact2, compact3

    Interface Map

    java.util

    Type Parameters:

    K - the type of keys maintained by this map

    V - the type of mapped values

    All Known Subinterfaces:

    Bindings, ConcurrentMap, ConcurrentNavigableMap, LogicalMessageContext, MessageContext, NavigableMap, SOAPMessageContext, SortedMap

    All Known Implementing Classes:

    AbstractMap, Attributes, AuthProvider, ConcurrentHashMap, ConcurrentSkipListMap, EnumMap, HashMap, Hashtable, IdentityHashMap, LinkedHashMap, PrinterStateReasons, Properties, Provider, RenderingHints, SimpleBindings, TabularDataSupport, TreeMap, UIDefaults, WeakHashMap

    public interface Map

    An object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value.

    This interface takes the place of the Dictionary class, which was a totally abstract class rather than an interface.

    The Map interface provides three , which allow a map's contents to be viewed as a set of keys, collection of values, or set of key-value mappings. The of a map is defined as the order in which the iterators on the map's collection views return their elements. Some map implementations, like the TreeMap class, make specific guarantees as to their order; others, like the HashMap class, do not.

    Note: great care must be exercised if mutable objects are used as map keys. The behavior of a map is not specified if the value of an object is changed in a manner that affects equals comparisons while the object is a key in the map. A special case of this prohibition is that it is not permissible for a map to contain itself as a key. While it is permissible for a map to contain itself as a value, extreme caution is advised: the equals and hashCode methods are no longer well defined on such a map.

    All general-purpose map implementation classes should provide two "standard" constructors: a void (no arguments) constructor which creates an empty map, and a constructor with a single argument of type Map, which creates a new map with the same key-value mappings as its argument. In effect, the latter constructor allows the user to copy any map, producing an equivalent map of the desired class. There is no way to enforce this recommendation (as interfaces cannot contain constructors) but all of the general-purpose map implementations in the JDK comply.

    The "destructive" methods contained in this interface, that is, the methods that modify the map on which they operate, are specified to throw UnsupportedOperationException if this map does not support the operation. If this is the case, these methods may, but are not required to, throw an UnsupportedOperationException if the invocation would have no effect on the map. For example, invoking the putAll(Map) method on an unmodifiable map may, but is not required to, throw the exception if the map whose mappings are to be "superimposed" is empty.

    Some map implementations have restrictions on the keys and values they may contain. For example, some implementations prohibit null keys and values, and some have restrictions on the types of their keys. Attempting to insert an ineligible key or value throws an unchecked exception, typically NullPointerException or ClassCastException. Attempting to query the presence of an ineligible key or value may throw an exception, or it may simply return false; some implementations will exhibit the former behavior and some will exhibit the latter. More generally, attempting an operation on an ineligible key or value whose completion would not result in the insertion of an ineligible element into the map may throw an exception or it may succeed, at the option of the implementation. Such exceptions are marked as "optional" in the specification for this interface.

    Many methods in Collections Framework interfaces are defined in terms of the equals method. For example, the specification for the containsKey(Object key) method says: "returns true if and only if this map contains a mapping for a key k such that (key==null ? k==null : key.equals(k))." This specification should be construed to imply that invoking Map.containsKey with a non-null argument key will cause key.equals(k) to be invoked for any key k. Implementations are free to implement optimizations whereby the equals invocation is avoided, for example, by first comparing the hash codes of the two keys. (The Object.hashCode() specification guarantees that two objects with unequal hash codes cannot be equal.) More generally, implementations of the various Collections Framework interfaces are free to take advantage of the specified behavior of underlying Object methods wherever the implementor deems it appropriate.

    Some map operations which perform recursive traversal of the map may fail with an exception for self-referential instances where the map directly or indirectly contains itself. This includes the clone(), equals(), hashCode() and toString() methods. Implementations may optionally handle the self-referential scenario, however most current implementations do not do so.

    स्रोत : docs.oracle.com

    java.util Package Multiple Choice Questions & Answers

    This is the java programming questions and answers section on

    java.util Package Multiple Choice Questions & Answers

    This is the java programming questions and answers section on "java.util Package" with explanation for various interview, competitive examination and entrance test. Solved examples with detailed answer description, explanation are given and it would be easy to understand.

    java.util Package Questions

    Online Test Name java.util PackageExam Type Multiple Choice QuestionsCategory Computer Science Engineering QuizNumber of Questions 45

    16. Which of these method Map class is used to obtain an element in the map having specified key?

    A. search() B. get() C. set() D. look() View Answer Workspace Report Discuss

    17. Which of these methods can be used to obtain set of all keys in a map?

    A. getAll() B. getKeys() C. keyall() D. keySet() View Answer Workspace Report Discuss

    18. Which of these method is used add an element and corresponding key to a map?

    A. put() B. set() C. redo() D. add() View Answer Workspace Report Discuss

    19. Which of these standard collection classes implements all the standard functions on list data structure?

    A. Array B. LinkedList C. HashSet D. AbstractSet View Answer Workspace Report Discuss

    20. Which of these classes implements Set interface?

    A. ArrayList B. HashSet C. LinkedList D. DynamicList View Answer Workspace Report Discuss « 1 2 3 4 5 6 7 8 9 »

    Related Topics:

    java.lang Package Strings

    Input Output Streams

    Operators Serialization Collections java.io Package Threads Data Types Exception Handling

    Mock Tests & Online Quizzes

    Aptitude Online Test

    Reasoning Online Test

    GK Online Test English Online Test RRB Mock Test RBI Mock Test Free SBI Mock Test IBPS Mock Test FREE SSC Mock Test CAT Exam Mock Test GATE Mock Test IT Courses Quiz

    स्रोत : www.allindiaexams.in

    Java.util

    This section of our 1000+ Java MCQs focuses on Maps of Java Programming Language. 1. Which of these object stores association between keys and values? a) Hash table b) Map c) Array d) String 2. Which of these classes provide implementation of map interface? a) ArrayList b) HashMap c) LinkedList d) DynamicList 3. Which of ... Read more

    Java Questions & Answers – Java.util – Maps

    « Prev Next »

    This section of our 1000+ Java MCQs focuses on Maps of Java Programming Language.

    1. Which of these object stores association between keys and values?

    a) Hash table b) Map c) Array d) String View Answer

    2. Which of these classes provide implementation of map interface?

    a) ArrayList b) HashMap c) LinkedList d) DynamicList View Answer

    3. Which of these method is used to remove all keys/values pair from the invoking map?

    a) delete() b) remove() c) clear() d) removeAll() View Answer

    Note: Join free Sanfoundry classes at Telegram or Youtube

    advertisement

    4. Which of these method Map class is used to obtain an element in the map having specified key?

    a) search() b) get() c) set() d) look() View Answer

    5. Which of these methods can be used to obtain set of all keys in a map?

    a) getAll() b) getKeys() c) keyall() d) keySet() View Answer

    Take Java Programming Mock Tests - Chapterwise!

    Start the Test Now: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

    6. Which of these method is used add an element and corresponding key to a map?

    a) put() b) set() c) redo() d) add() View Answer

    7. What will be the output of the following Java program?

    advertisement import java.util.*; class Maps {

    public static void main(String args[])

    {

    HashMap obj = new HashMap();

    obj.put("A", new Integer(1));

    obj.put("B", new Integer(2));

    obj.put("C", new Integer(3));

    System.out.println(obj);

    } } a) {A 1, B 1, C 1} b) {A, B, C} c) {A-1, B-1, C-1} d) {A=1, B=2, C=3} View Answer

    8. What will be the output of the following Java program?

    import java.util.*; class Maps {

    public static void main(String args[])

    {

    HashMap obj = new HashMap();

    obj.put("A", new Integer(1));

    obj.put("B", new Integer(2));

    obj.put("C", new Integer(3));

    System.out.println(obj.keySet());

    } } a) [A, B, C] b) {A, B, C} c) {1, 2, 3} d) [1, 2, 3] View Answer

    9. What will be the output of the following Java program?

    import java.util.*; class Maps {

    public static void main(String args[])

    {

    HashMap obj = new HashMap();

    obj.put("A", new Integer(1));

    obj.put("B", new Integer(2));

    obj.put("C", new Integer(3));

    System.out.println(obj.get("B"));

    } } a) 1 b) 2 c) 3 d) null View Answer

    10. What will be the output of the following Java program?

    import java.util.*; class Maps {

    public static void main(String args[])

    {

    TreeMap obj = new TreeMap();

    obj.put("A", new Integer(1));

    obj.put("B", new Integer(2));

    obj.put("C", new Integer(3));

    System.out.println(obj.entrySet());

    } } a) [A, B, C] b) [1, 2, 3] c) {A=1, B=2, C=3} d) [A=1, B=2, C=3] View Answer

    Sanfoundry Global Education & Learning Series – Java Programming Language.

    To practice all areas of Java language, here is complete set of 1000+ Multiple Choice Questions and Answers.

    « Prev - Java Questions & Answers – Java.util – LinkedList, HashSet & TreeSet Class

    » Next - Java Questions & Answers – Java.util – Vectors & Stack

    Next Steps:

    Get Free Certificate of Merit in Java Programming

    Participate in Java Programming Certification Contest

    Become a Top Ranker in Java Programming

    Take Java Programming Tests

    Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

    Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

    Related Posts:

    Apply for Java Internship

    Practice Information Technology MCQs

    Buy Programming Books

    Practice Programming MCQs

    Practice BCA MCQs advertisement

    Recommended Articles:

    Java Questions & Answers – Java.util – Vectors & Stack

    Java Questions & Answers – Java.util – LinkedList, HashSet & TreeSet Class

    Java Questions & Answers – Java.util – Dictionary, Hashtable & Properties

    Java Questions & Answers – Java.util – BitSet & Date class

    Java Questions & Answers – Java.util – ArrayList Class

    Java Questions & Answers – Java.util – Array Class

    Java Program to Implement HashMap API

    Java Questions & Answers – Data Structures-HashMap

    Java Questions & Answers – Data Structures-Set

    Java Programs on Collections

    advertisement

    Additional Resources:

    Java Programs on Collections

    Java Programs on Classes and Objects

    Event Handling in Java with Examples

    Java Programming Examples

    Java Programming MCQ Questions

    Popular Pages:

    Java Applet Programs

    Java String Programs

    Java Array Programs

    Sorting Algorithms in Java

    Tree Programs in Java

    स्रोत : www.sanfoundry.com

    Do you want to see answer or more ?
    Mohammed 11 day ago
    4

    Guys, does anyone know the answer?

    Click For Answer