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

Given:

and

and

and

What needs to change to make these classes compile and still handle all types of Interface Worker?

    Correct Answer: A

    The issue lies in the generic type bounds and method parameter types. The class Main<T extends Worker> is designed to handle any type that implements the Worker interface. However, the method addProcess(HardWorker w) specifically requires an instance of HardWorker, which contradicts the flexibility offered by the generic type T. To make the class generic and compatible with any Worker, the parameter type in the addProcess method should be changed to Worker. This ensures that the processes list can hold any type of Worker, fulfilling the intended purpose of handling all types that implement the Worker interface. Therefore, replacing Line 3 with public void addProcess(Worker w) { solves the issue.

Discussion
mendjijetOption: D

Tested D is ok

d7bb0b2Option: D

d is ok

OmnisumemOption: D

Tested: D.

tmuralimanoharOption: D

Answer: D

StavokOption: D

D is correct replace line 3 with public void addProcess(T w) {