Which method is used to add an element to an ArrayList?
- add()
- append()
- insert()
- push()
The add() method is used to add an element to an ArrayList in Java. It appends the specified element to the end of the list. Other methods like insert(), append(), and push() are not used for adding elements to ArrayLists.
Loading...
Related Quiz
- How does Java handle overriding methods that throw exceptions?
- How would you handle a situation where a task submitted to ExecutorService is stuck or running for too long?
- Which of the following statements about constructor overloading in Java is correct?
- The ________ keyword is used to declare objects that cannot change.
- The ________ block can be used to handle different types of exceptions in a single block.