Page 1 of 1

About Question enthuware.ocpjp.v17.2.3703 :

Posted: Mon Jul 17, 2023 1:34 pm
by edufin166@yahoo.com
WOuld not be "There is no problem with any of the marked lines but the given code will not compile." the correct alternative?

Where is the implementation of the method "role" in Person-Record?

""

sealed interface Member permits Student, Person{ //LINE A
String role(); }

record Person(String role) implements Member{ //LINE B }

Thx

Re: About Question enthuware.ocpjp.v17.2.3703 :

Posted: Mon Jul 17, 2023 9:38 pm
by admin
What happened when you tried compiling the code?

Person is a record and it declares a parameter named role. So, a method named role() will be provided automatically by the compiler.