Que- Which of these method of DatagramPacket is used to find the port number?
a. port()
b. getPort()
c. findPort()
d. recievePort()
Answer- getPort()
Que- Which of these method of DatagramPacket is used to obtain the byte array of data contained in a datagram?
a. getData()
b. getBytes()
c. getArray()
d. recieveBytes()
Answer- getData()
Que- Which of these methods of DatagramPacket is used to find the length of byte array?
a. getnumber()
b. length()
c. Length()
d. getLength()
Answer- getLength()
Que- Which of these class must be used to send a datagram packets over a connection?
a. InetAdress
b. DatagramPacket
c. DatagramSocket
d. All of the mentioned
Answer- All of the mentioned
Que- Which of these method of DatagramPacket class is used to find the destination address?
a. findAddress()
b. getAddress()
c. Address()
d. whois()
Answer- getAddress()
Que- Which of these is a return type of getAddress() method of DatagramPacket class?
a. DatagramPacket
b. DatagramSocket
c. InetAddress
d. ServerSocket
Answer- InetAddress
Que- Which API gets the SocketAddress (usually IP address + port number) of the remote host that this packet is being sent to or is coming from.
a. getSocketAddress()
b. getAddress()
c. address()
d. none of the mentioned
Answer- getSocketAddress()
Que- Which of these standard collection classes implements a dynamic array?
a. AbstractList
b. LinkedList
c. ArrayList
d. AbstractSet
Answer- ArrayList
Que- Which of these class can generate an array which can increase and decrease in size automatically?
a. ArrayList()
b. DynamicList()
c. LinkedList()
d. MallocList()
Answer- ArrayList()
Que- Which of these method can be used to increase the capacity of ArrayList object manually?
a. Capacity()
b. increaseCapacity()
c. increasecapacity()
d. ensureCapacity()
Answer- ensureCapacity()
Que- Which of these method of ArrayList class is used to obtain present size of an object?
a. size()
b. length()
c. index()
d. capacity()
Answer- size()
Que- Which of these methods can be used to obtain a static array from an ArrayList object?
a. Array()
b. covertArray()
c. toArray()
d. covertoArray()
Answer- toArray()
Que- Which of these method is used to reduce the capacity of an ArrayList object?
a. trim()
b. trimSize()
c. trimTosize()
d. trimToSize()
Answer- trimToSize()
Que- Which of the below does not implement Map interface?
a. HashMap
b. Hashtable
c. EnumMap
d. Vector
Answer- Vector
Que- What is the premise of equality for IdentityHashMap?
a. Reference equality
b. Name equality
c. Hashcode equality
d. Length equality
Answer- Reference equality
Que- What happens if we put a key object in a HashMap which exists?
a. The new object replaces the older object
b. The new object is discarded
c. The old object is removed from the map
d. It throws an exception as the key already exists in the map
Answer- The new object replaces the older object
Que- While finding the correct location for saving key value pair, how many times the key is hashed?
a.1
b.2
c.3
d. unlimited till bucket is found
Answer-2
Que- Is hashmap an ordered collection.
a.TRUE
b.FALSE
c.Nothing Can be Said
d.None of the mentioned
Answer-FALSE
Que- If two threads access the same hashmap at the same time, what would happen?
a. ConcurrentModificationException
b. NullPointerException
c. ClassNotFoundException
d. RuntimeException
Answer- ConcurrentModificationException
Que- How can we remove an object from ArrayList?
a. remove() method
b. using Iterator
c. remove() method and using Iterator
d. delete() method
Answer- remove() method and using Iterator
Que- How to remove duplicates from List?
a. HashSet<String> listToSet = new HashSet<String>(duplicateList);
b. HashSet<String> listToSet = duplicateList.toSet();
c. HashSet<String> listToSet = Collections.convertToSet(duplicateList);
d. HashSet<String> listToSet = duplicateList.getSet();
Answer- HashSet<String> listToSet = new HashSet<String>(duplicateList);
Que- How to sort elements of ArrayList?
a. Collection.sort(listObj);
b. Collections.sort(listObj);
c. listObj.sort();
d. Sorter.sortAsc(listObj);
Answer- Collections.sort(listObj);
Que- When two threads access the same ArrayList object what is the outcome of the program?
a. Both are able to access the object
b. ConcurrentModificationException is thrown
c. One thread is able to access the object and second thread gets Null Pointer exception
d. One thread is able to access the object and second thread will wait till control is passed to the second one
Answer- ConcurrentModificationException is thrown
Que- How is Arrays.asList() different than the standard way of initialising List?
a. Both are same
b. Arrays.asList() throws compilation error
c. Arrays.asList() returns a fixed length list and doesn't allow to add or remove elements
d. We cannot access the list returned using Arrays.asList()
Answer- Arrays.asList() returns a fixed length list and doesn't allow to add or remove elements
Que- What is the difference between length() and size() of ArrayList?
a. length() and size() return the same value
b. length() is not defined in ArrayList
c. size() is not defined in ArrayList
d. length() returns the capacity of ArrayList and size() returns the actual number of elements stored in the list
Answer- length() returns the capacity of ArrayList and size() returns the actual number of elements stored in the list
Que- Which class provides thread safe implementation of List?
a. ArrayList
b. CopyOnWriteArrayList
c. HashList
d. List
Answer- CopyOnWriteArrayList
Que- Which of the below is not an implementation of List interface?
a. RoleUnresolvedList
b. Stack
c. AttibuteList
d. SessionList
Answer- SessionList