About Question enthuware.ocpjp.v17.2-.-3689
Posted: Fri Nov 11, 2022 7:59 am
This question:
and 1st option, which is correct answer:
The code will compile fine if both A and B are part of the same named module.
All permitted subtypes of a sealed type must either belong to the same package or to the same module.
Appropriate import statements are required(or using qualified names: extends p1.A, permits p2.B).
And public modifiers too.(sorry for forgetting)
OR,
Clearly A and B can't be compiled even if A and B are part of the same named module.
So 1st option is not correct answer.
1st option of enthuware.ocpjp.v17.2.3684 explains:
All permitted subclasses of a sealed class must belong to the same package (or belong to the same named module).
Since no module information is given in the problem statement, you should assume that there is no module in play here.
This question gives no module information too.
Maybe there is no problem of module, maybe in the same module.
and 2nd option is:
Both the classes must belong to the same package for the code to compile.
A and B have default access control.
So if A and B belong to the same package, they can be compiled.
2nd option is not incorrect.
In addition,
1st option explains:
All permitted subtypes of a sealed type must either belong to the same package or to the same module.
It is not appropriate.
As the explanation of this question, it should be based on JLS.
same named module, or beloging to unnamed modules, same package.
2nd option explains:
It is not necessary of both the classes belong to the same named module.
Sorry, I can't understand what it means.
And
With ETS Viewer, "Tools" > "Check for Question Bank Update" shows:
Message from Server:Current Major/Minor Version Numbers are: 1/14
The version you are currently using is: 1/18
Update check doesn't work.
and the version of previous 1z0-829.ets is 1/18 too.
Code: Select all
//in file A.java
package p1;
sealed class A permits B{
}
//in file B.java
package p2;
final class B extends A{
}
The code will compile fine if both A and B are part of the same named module.
All permitted subtypes of a sealed type must either belong to the same package or to the same module.
Appropriate import statements are required(or using qualified names: extends p1.A, permits p2.B).
And public modifiers too.(sorry for forgetting)
OR,
Clearly A and B can't be compiled even if A and B are part of the same named module.
So 1st option is not correct answer.
1st option of enthuware.ocpjp.v17.2.3684 explains:
All permitted subclasses of a sealed class must belong to the same package (or belong to the same named module).
Since no module information is given in the problem statement, you should assume that there is no module in play here.
This question gives no module information too.
Maybe there is no problem of module, maybe in the same module.
and 2nd option is:
Both the classes must belong to the same package for the code to compile.
A and B have default access control.
So if A and B belong to the same package, they can be compiled.
2nd option is not incorrect.
In addition,
1st option explains:
All permitted subtypes of a sealed type must either belong to the same package or to the same module.
It is not appropriate.
As the explanation of this question, it should be based on JLS.
same named module, or beloging to unnamed modules, same package.
2nd option explains:
It is not necessary of both the classes belong to the same named module.
Sorry, I can't understand what it means.
And
With ETS Viewer, "Tools" > "Check for Question Bank Update" shows:
Message from Server:Current Major/Minor Version Numbers are: 1/14
The version you are currently using is: 1/18
Update check doesn't work.
and the version of previous 1z0-829.ets is 1/18 too.