0% found this document useful (0 votes)
7 views1 page

7.list in Java

The document contains practice questions for ArrayList, LinkedList, Vector, and Stack in Java. It includes tasks such as creating lists, manipulating elements, copying, sorting, and implementing a menu-driven stack program. Each section provides specific exercises aimed at enhancing understanding of these data structures.

Uploaded by

shivamverma63970
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

7.list in Java

The document contains practice questions for ArrayList, LinkedList, Vector, and Stack in Java. It includes tasks such as creating lists, manipulating elements, copying, sorting, and implementing a menu-driven stack program. Each section provides specific exercises aimed at enhancing understanding of these data structures.

Uploaded by

shivamverma63970
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

​ ArrayList Practice Questions-

Q1. Create a List of integers using ArrayList, and add 5 elements. Print them
using a for-each loop.

Q2. Insert an element at a specific index and remove one.

Q3. Write a program to copy all elements from one ArrayList to another.

Q4. Sort an ArrayList of integers and print the maximum and minimum value.

Q5. Write a method that takes an ArrayList<String> and returns another


ArrayList with only strings that start with the letter 'A'.

2.​ LinkedList Practice Questions-

Q1. Create a LinkedList of city names and perform:

Add elements at the beginning and end

Remove the first and last element

Q2. Use getFirst() and getLast() to retrieve elements.

(Tip: Use LinkedList<String> directly instead of List to access these)

3.​ Vector Practice Questions-

Q8. Create a Vector<Integer> with 10 elements and remove all elements using
removeAllElements().

Q9. Demonstrate how Vector is synchronized by showing multiple threads adding to it.

4.​ Stack Practice Questions-


Q1. Implement a menu-driven program:
a. Push element
b. Pop element
c. Peek top
d. Display stack
e. Exit
Q2. Reverse a string using Stack<Character>.

You might also like