About Question enthuware.ocpjp.v11.2.1770 :
Moderator: admin
-
- Posts: 2
- Joined: Mon May 30, 2022 1:48 pm
- Contact:
About Question enthuware.ocpjp.v11.2.1770 :
It will compile and print 30.
But answer is mentioned as Compilation error.
But answer is mentioned as Compilation error.
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.1770 :
Please make sure you have copied the code exactly as given.
-
- Posts: 10
- Joined: Wed Nov 23, 2022 3:40 am
- Contact:
Re: About Question enthuware.ocpjp.v11.2.1770 :
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.
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.1770 :
Again, the question and the given answer/explanation are correct. Copy the code exactly as given and try compiling it from the command line.
-
- Posts: 5
- Joined: Mon Aug 12, 2024 4:18 am
- Contact:
Re: About Question enthuware.ocpjp.v11.2.1770 :
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.
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.
-
- Posts: 167
- Joined: Sun Apr 21, 2024 10:43 am
- Contact:
Re: About Question enthuware.ocpjp.v11.2.1770 :
how can i have compilation failure at line 1 and the following line
compiler only cares about the first error?
compiler only cares about the first error?
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.1770 :
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.
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.
-
- Posts: 167
- Joined: Sun Apr 21, 2024 10:43 am
- Contact:
Who is online
Users browsing this forum: No registered users and 7 guests