Page 1 of 1

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

Posted: Tue Oct 17, 2017 7:47 am
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!!

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

Posted: Tue Oct 17, 2017 10:33 am
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.

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

Posted: Tue Oct 17, 2017 11:55 am
by Javier
Thank you very much Enthuware!!

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

Posted: Tue Jul 11, 2023 9:20 am
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);} ???

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

Posted: Tue Jul 11, 2023 10:44 am
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".