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!!
About Question enthuware.ocajp.i.v8.2.1334 :
Moderator: admin
-
- Posts: 66
- Joined: Mon Feb 20, 2017 12:31 pm
- Contact:
-
- Site Admin
- Posts: 10398
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1334 :
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 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.
-
- Posts: 66
- Joined: Mon Feb 20, 2017 12:31 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1334 :
Thank you very much Enthuware!!
-
- Posts: 24
- Joined: Wed Sep 28, 2022 9:41 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1334 :
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);} ???
In order to "print"....
The correct would not be "A(String s1, String s2){ System.out.println(s1 + s2);} ???
-
- Site Admin
- Posts: 10398
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1334 :
Not sure what you mean. You have to run the complete code as given in the question. It does print "good bye world".
Who is online
Users browsing this forum: No registered users and 9 guests