About Question enthuware.ocpjp.v11.2.1770 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
kaleemkhan.java
Posts: 2
Joined: Mon May 30, 2022 1:48 pm
Contact:

About Question enthuware.ocpjp.v11.2.1770 :

Post by kaleemkhan.java »

It will compile and print 30.

But answer is mentioned as Compilation error.

admin
Site Admin
Posts: 10384
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v11.2.1770 :

Post by admin »

Please make sure you have copied the code exactly as given.

asi-aal
Posts: 10
Joined: Wed Nov 23, 2022 3:40 am
Contact:

Re: About Question enthuware.ocpjp.v11.2.1770 :

Post 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.

admin
Site Admin
Posts: 10384
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v11.2.1770 :

Post 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.

wojciechblo
Posts: 5
Joined: Mon Aug 12, 2024 4:18 am
Contact:

Re: About Question enthuware.ocpjp.v11.2.1770 :

Post 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.

raphaelzintec
Posts: 167
Joined: Sun Apr 21, 2024 10:43 am
Contact:

Re: About Question enthuware.ocpjp.v11.2.1770 :

Post by raphaelzintec »

how can i have compilation failure at line 1 and the following line

compiler only cares about the first error?

admin
Site Admin
Posts: 10384
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v11.2.1770 :

Post 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.

raphaelzintec
Posts: 167
Joined: Sun Apr 21, 2024 10:43 am
Contact:

Re: About Question enthuware.ocpjp.v11.2.1770 :

Post by raphaelzintec »

thank you!

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests