Web Design and Development MCQs with Answers
Practice important Web Design and Development MCQs with answers and explanations.
Multiple Choice Questions
Q91: Which method removes an element at a specified index in an ArrayList?
- A: delete()
- B: remove()
- C: erase()
- D: discard()
View Answer
B
Q92: How are elements stored in a HashMap?
- A: In a list
- B: In a set
- C: As key-value pairs
- D: In a queue
View Answer
C
Q93: What does the put(Object key, Object value) method do in a HashMap?
- A: Retrieves the value for a given key
- B: Replaces the value for a given key
- C: Deletes a key-value pair
- D: Adds a key-value pair
View Answer
D
Q94: Which method of HashMap returns the value associated with a given key?
- A: get()
- B: find()
- C: fetch()
- D: search()
View Answer
A
Q95: How do you check if a HashMap is empty?
- A: isEmpty()
- B: checkEmpty()
- C: hasNoElements()
- D: empty()
View Answer
A
Q96: In Java, what does up-casting involve?
- A: Converting a larger data type to a smaller one
- B: Converting a smaller data type to a larger one
- C: Implicit casting
- D: Explicit casting
View Answer
B
Q97: What type of casting is required when converting a larger data type to a smaller one?
- A: Up-casting
- B: Down-casting
- C: Implicit casting
- D: Automatic casting
View Answer
B
Q98: Which class provides the capability to store key-value pairs in Java?
- A: ArrayList
- B: HashSet
- C: HashMap
- D: LinkedList
View Answer
C
Q99: What is the main purpose of the remove(Object o) method in a collection?
- A: To add an object
- B: To check if an object is present
- C: To remove a specific object
- D: To replace an object
View Answer
C
Q100: How do you iterate over elements in an ArrayList?
- A: Using a for-each loop
- B: Using a while loop
- C: Using a do-while loop
- D: Using a for loop
View Answer
A