Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What is the output of this program? 1. import java.util.*; 2. class Arraylist {3

ID: 3836112 • Letter: W

Question

What is the output of this program? 1. import java.util.*; 2. class Arraylist {3. public static void main(String args[]) {4. ArrayList obj = new ArrayList(); 5. obj.add("London"); 6. obj.add ("Paris"); 7. obj.add("Tokyo"); 8. obj.add(1, "Newark") 9. System.out.println(obj); 10.} 11.} What is the output of this program? 1. import java.util. *; 2. class Output {3. public static void main(String args[]) {4. ArrayList obj = new ArrayList(); 5. obj.add("A"); 6. obj.add ("0, "B"); 7. for (String s: obj) 8. System.out.println(s); 9.} 10.}

Explanation / Answer

The following programs will give compilation error as the function add is not defined anywhere in the program Hence it will throw the following compilation error:

the method add(String) is undefined for the type class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote