1z0-819 Exam QuestionsBrowse all questions from this exam

1z0-819 Exam - Question 98


Given:

and

Which two lines can replace line 1 so that the Y class compiles? (Choose two.)

Show Answer
Correct Answer: CE

The Y class contains a method that overrides the set method from the X class, but with a Map<String, String> parameter instead of a Collection parameter. The goal is to replace line 1 with a statement that correctly compiles. Both options C and E meet the criteria since the map.values() method returns a Collection, which aligns with the parameter type expected by the set method in the superclass. Option C calls the set method with map.values(), satisfying the method signature in class X. Similarly, option E uses super.set(map.values()) to invoke the superclass method with a Collection parameter, ensuring the code compiles.

Discussion

4 comments
Sign in to comment
StavokOptions: CE
Jul 18, 2023

The two lines that can replace line 1 so that the Y class compiles are C. set(map.values()) and E. super.set(map.values()). Option C is correct because it calls the set() method with the result of calling the values() method on the map object, which returns a Collection of the values in the map. Option E is correct because it calls the set() method in the superclass (Question98) with the result of calling the values() method on the map object, which returns a Collection of the values in the map.

dillemanOptions: CE
Sep 29, 2023

C and E

OmnisumemOptions: CE
Oct 17, 2023

Tested: C, E.

ASPushkinOptions: CD
Jun 19, 2024

answer: CED D correct this is the recursion public void set(Map<String,String> map) { set(map); } CE correct Map Collection<V> values() so Map Collection<V> values() set(Collection<String>) - Ok