About Question enthuware.ocajp.i.v7.2.907 :

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

Moderator: admin

Post Reply
mistervernon
Posts: 1
Joined: Wed Jul 23, 2014 9:46 am
Contact:

About Question enthuware.ocajp.i.v7.2.907 :

Post by mistervernon »

Hi (awesome product!).
...your explanation to this question reads:
"Note that if a subclass class constructor doesn't explicitly call the super class constructor, the compiler automatically inserts super(); as the first statement of the base class constructor. So option 5 is not needed."

However, I believe that the explanation should read:
"Note that if a subclass class constructor doesn't explicitly call the super class constructor, the compiler automatically inserts super(); as the first statement of the subclass class constructor. So option 5 is not needed."



.... I think!?

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

Re: About Question enthuware.ocajp.i.v7.2.907 :

Post by admin »

Hi,
You don't seem to have the latest version of the question bank because I see that it has already been fixed.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

JaredTse
Posts: 20
Joined: Sat Apr 23, 2016 2:52 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.907 :

Post by JaredTse »

I just need a minor clarification on this. My understanding of inheritance is that If a Subleases does not have any constructors, then the compiler inserts a default no args constructor which calls the Supperclass no args Constructor. However if you supply a constructor in this case a constructor with a single arg. Then the compiler does not insert the default constructor.

Then my question is, how is the superclass constructor been called ?
is there super() method inserted at compile time on the Constructor that takes a single arg on subclass?
and also does the super() method gets inserted on all the constructors at compile time regardless of number of args ?
Finally I do not see the super() method on the .class files, is it supposed be there ?

Thanks

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

Re: About Question enthuware.ocajp.i.v7.2.907 :

Post by admin »

Yes, if you don't explicitly call any superclass constructor in your constructor, then the compiler automatically inserts a call to super(); at the first line.
super(); is not a method and is not a method call. It is a syntax to call the super class's constructor that takes no arguments.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

daromnik
Posts: 2
Joined: Sat Mar 13, 2021 4:20 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.907 :

Post by daromnik »

Hi.
But this code doesn't compile, because "No "public class" found to execute".
Isn't that right?

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

Re: About Question enthuware.ocajp.i.v7.2.907 :

Post by admin »

1. A class doesn't need to be public for successful compilation.
2. "No "public class" found to execute" means you are trying to execute it. Execution is after compilation. That means, it has already compiled.
3. A class doesn't need to be public for execution either. Only the main method needs to be public.
4. You seem to be using an IDE. Please use compile and run it from command line. IDEs are known to cause confusion by showing custom error messages and are not recommended while preparing for the exam.
If you like our products and services, please help us by posting your review here.

daromnik
Posts: 2
Joined: Sat Mar 13, 2021 4:20 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.907 :

Post by daromnik »

Thank you very much!

en.builin@gmail.com
Posts: 1
Joined: Mon Aug 28, 2023 11:44 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.907 :

Post by en.builin@gmail.com »

Make Eagle class declaration public:
public class Eagle { ... }


It can be right answer. Class declaration doesn't have extends keyword, so super() wouldn't be called. Filename is Eagle.java, so it will compile.
Am I right?

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

Re: About Question enthuware.ocajp.i.v7.2.907 :

Post by admin »

You are right. The option is missing the extends part and without the extends part, it would make the code valid. Should be fixed.
thank you for your feedback!
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: gadsgadsx and 75 guests