Page 1 of 1

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

Posted: Mon Apr 24, 2017 5:28 am
by rowan.jones
This question doesn't quite make sense to me.

Consider the options written out.

1 must be valid.

2 is a method, not a constructor.

3 would be written like

Code: Select all

public TestClass(String s);
Which is wrong. At first glance you might think it's for an interface, but interfaces don't have constructors.

4 must be correct.

5 would be written like

Code: Select all

public TestClass(String s1, String s2){

};
which is wrong since it has a ; at the end.

I can only see 2 valid constructors in this question.

Could someone enlighten me to the 3rd correct option?

Thanks! :)

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

Posted: Mon Apr 24, 2017 8:45 am
by admin
Did you read the explanation written below the 5th option?
The compiler ignores the extra semi-colon.
HTH,
Paul.

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

Posted: Sat May 19, 2018 7:37 am
by flex567
The explanation for //3 is that the constructor has empty body.
But all other have empty body (only have brackets)??

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

Posted: Sun May 20, 2018 12:23 pm
by admin
It also explains further what it means by empty (it cannot be abstract). I have updated the explanation to make it more clear.

thank you for your feedback!