Page 1 of 1
About Question enthuware.ocpjp.v11.2.1770 :
Posted: Mon May 30, 2022 1:53 pm
by kaleemkhan.java
It will compile and print 30.
But answer is mentioned as Compilation error.
Re: About Question enthuware.ocpjp.v11.2.1770 :
Posted: Mon May 30, 2022 10:38 pm
by admin
Please make sure you have copied the code exactly as given.
Re: About Question enthuware.ocpjp.v11.2.1770 :
Posted: Tue Feb 07, 2023 2:45 am
by asi-aal
This question is not correct, please review it. It gives no compilation error and as mentioned that interface's variables are never inherited and can be accessed only by the name of the interface class.
Re: About Question enthuware.ocpjp.v11.2.1770 :
Posted: Tue Feb 07, 2023 10:39 am
by admin
Again, the question and the given answer/explanation are correct. Copy the code exactly as given and try compiling it from the command line.
Re: About Question enthuware.ocpjp.v11.2.1770 :
Posted: Sat Aug 17, 2024 6:11 pm
by wojciechblo
If Fruit declaration will be:
public class Fruit extends Food { //LINE1
then field 'types' in Food will hide 'types' in Eatable, so no problem.
But, when it is declared as:
public class Fruit extends Food implements Eatable { //LINE1
then in body of Fruit 'types' from Food has the same visibility scope as 'types' from Eatable - so, ambiguous reference will be.
Re: About Question enthuware.ocpjp.v11.2.1770 :
Posted: Sat Feb 15, 2025 8:28 am
by raphaelzintec
how can i have compilation failure at line 1 and the following line
compiler only cares about the first error?
Re: About Question enthuware.ocpjp.v11.2.1770 :
Posted: Sat Feb 15, 2025 9:28 pm
by admin
With questions that ask about compilation errors, you are expected to identify all errors that the compiler will notice when you try to compile the code.
Most problem statements use a standard format/style such as, "What will the following code print when compiled and run? ". But if you see multiple compilation issues, you should pick them all even if you think that the compiler will stop after encountering the first error.
Re: About Question enthuware.ocpjp.v11.2.1770 :
Posted: Sun Feb 16, 2025 11:57 am
by raphaelzintec
thank you!