About Question enthuware.ocajp.i.v8.2.1334 :

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

Moderator: admin

Post Reply
Javier
Posts: 66
Joined: Mon Feb 20, 2017 12:31 pm
Contact:

About Question enthuware.ocajp.i.v8.2.1334 :

Post by Javier »

Hi!!

I just would like to confirm one thing about constructors.

One of the rules constructor (OCA 8, Jeanne Boyarsky and Scott Selikoff) says that: "If no super() call is declared in a constructor, Java will insert a no-argument super() as the first statement of the constructor", it doesn´t matter if there are more constructors in the class?:

B(){ super("good bye"); };
B(String s){ }//here the JVM introduce a super(), isn´t it???
B(String s1, String s2){ this(s1 + s2 + " ! "); }

Thank you very much Enthuware!!

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

Re: About Question enthuware.ocajp.i.v8.2.1334 :

Post by admin »

You should update the rule as:
If no super() or this() call is declared in the first line of a constructor, Java will insert a no-argument super() as the first statement of the constructor.
If you like our products and services, please help us by posting your review here.

Javier
Posts: 66
Joined: Mon Feb 20, 2017 12:31 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1334 :

Post by Javier »

Thank you very much Enthuware!!

edufin166@yahoo.com
Posts: 24
Joined: Wed Sep 28, 2022 9:41 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1334 :

Post by edufin166@yahoo.com »

Where Am I "printing" "good bye world"??
In order to "print"....

The correct would not be "A(String s1, String s2){ System.out.println(s1 + s2);} ???

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

Re: About Question enthuware.ocajp.i.v8.2.1334 :

Post by admin »

Not sure what you mean. You have to run the complete code as given in the question. It does print "good bye world".
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 42 guests