Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 103

Given the code fragment:

What is the result?

    Correct Answer: C

    In the provided code fragment, two ArrayLists are created and manipulated. For the first list, vegetables, 'Kale' is added first, followed by 'Lettuce' added at index 0, making the list ['Lettuce', 'Kale']. For the second list, fish, 'Salmon' is added first, followed by 'Seabass' added at index 0, making the list ['Seabass', 'Salmon']. When both lists are printed, the output will be [Lettuce, Kale] for the vegetables list and [Seabass, Salmon] for the fish list. Therefore, the correct result is [Lettuce, Kale] [Seabass, Salmon].

Discussion
ASPushkinOption: C

AbstractCollection already overrides toString() to print the contents of its elements. So, just list.toString() prints the toString() of all its elements. This is true for all collections. public StringBuilder append​(Object obj) Appends the string representation of the Object argument.

f91f9beOption: C

C is correct

d7bb0b2Option: C

C is correct, add method in list has two implementatios whit a element o with index and element

TheOneAboveAllOption: C

List vegetables = new ArrayList<> () ; vegetables.add ("Kale"); vegetables.add (0, "Lettuce"); System.out.println (vegetables); List fish = new ArrayList<> (); fish.add ("Salmon"); fish.add(0, "Seabass"); System.out.println(fish); Tested: C.

OmnisumemOption: C

Tested: C.

[Removed]Option: C

C is correct. There's no compilation error

StavokOption: B

B is correct Tested

Ashan_Ozlov

did u test?

ObaltOption: C

Correct answer is C