Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

18. What is the output of the following program segment? ArrayList people = new ArrayList 0; people.add(Kathy Coleman); people.add(Tom Terrific); System.out.println(people); (A) Kathy Coleman Tom

image text in transcribed

image text in transcribed

image text in transcribed

18. What is the output of the following program segment? ArrayList people = new ArrayList0; people.add("Kathy Coleman"); people.add("Tom Terrific"); System.out.println(people); (A) Kathy Coleman Tom Terrific (B) Tom Terrific Kathy Coleman (C) [Kathy Coleman, Tom Terrific] 19. (D) Error What is the output of the following program segment? ArrayList people = new ArrayList(); people.add("Kathy Coleman"); people.add(new Integer(1000)); System.out.println(people); (A) Kathy Coleman 1000 (B) 1000 Kathy Coleman (C) [Kathy Coleman, 1000] (D) Error 20. What is the output of the following program segment? ArrayList people = new ArrayList0; people.add("Kathy Coleman"); people.add(new Integer(1000)); System.out.println(people); (A) Kathy Coleman 1000 (B) 1000 Kathy Coleman (C) [Kathy Coleman, 1000] (D) Error 21. Consider the following program segment. ArrayList names = new ArrayList0; names.add("Isolde"); names.add("John"); names.add("Greg"); names.add("Maria"); Which of the following statements display all the elements in the names array? (A) System.out.println(names); (B) for (int index=0; index list = new ArrayList0; Which of the following statements stores "Kathy" in the list array: (A) list.add("Kathy"); (B) for (String item: list) item="Kathy"; (C) list[10] = "Kathy": 23. (D) All of the above Consider the following program segment. ArrayList names1 = new ArrayList0; ArrayList names 2 = new ArrayList0; names1.add("Isolde"); names1.add("John"); names1.add("Greg"); names1.add("Maria"); names1.add("Heidi"); for (String name: names1) names2.add(name); Which of the following statements describes the correct execution of the program segment? (A) The segment cannot execute due to a compile error. (B) The elements of names are copied into names2 in reverse order. (C) The elements of names are copied into names2 in the same order. (D) The elements of names are copied into names in the same order. 24. Consider the following program segment. ArrayList names1 = new ArrayList0; ArrayList names2 = new ArrayList0; names1.add("Isolde"); names1.add("John"); names1.add("Greg"); names1.add("Maria"); names1.add("Heidi"); for (String name: names2) names1.add(name); System.out.println(names1); What is the output as a result of executing the program segment? (A) (B) (C) (D) [Isolde, John, Greg, Maria, Heidi) [Isolde, John, Greg, Maria, Heidi, Isolde, John, Greg, Maria, Heidi] U The segment cannot execute due to a compile error. 25. Consider the following program segment. ArrayList names = new ArrayList0; names.add("Isolde"); names.add("John"); names.add("Greg"); names.add("Maria"); names.add("Heidi"); for (String name: names) names.add(name); System.out.println(names) ; What is the output as a result of executing the program segment? (A) (B) (C) (D) [Isolde, John, Greg, Maria, Heidi] [Isolde, John, Greg, Maria, Heidi, Isolde, John, Greg, Maria, Heidi] Compile error message Program crashes during execution with a runtime exception errors

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions