Page 1 of 1
About Question enthuware.ocajp.i.v7.2.947 :
Posted: Sat Mar 09, 2013 4:28 pm
by The_Nick
Hi,
I thought that it was line 4 as even though the "x" and "y" variables are not initialized (hence the code will not compile), as a constructor should be consider valid. No?
It cannot start with a tilde? I don't see why it's not a valid constructor besides the fact that does not compile.
Thanks in advance.
Re: About Question enthuware.ocajp.i.v7.2.947 :
Posted: Sat Mar 09, 2013 4:40 pm
by admin
You can't start a method or constructor with ~. It will not compile because of that as well.
Re: About Question enthuware.ocajp.i.v7.2.947 :
Posted: Sun Mar 10, 2013 4:43 am
by The_Nick
So making a recap, to be a correct identifier it must be of a range of letter [A-Z] [a-z] digits [0-9]. It must not begin with a digit. $ and _ are also valid character.
That's what I found on line. But I also noticed that an identifier as int £34$_ =10; works well.
Does it mean that any currency symbol can be used in an identifier?
Thanks in advance.
The_Nick
Re: About Question enthuware.ocajp.i.v7.2.947 :
Posted: Sun Mar 10, 2013 6:45 am
by admin
Re: About Question enthuware.ocajp.i.v7.2.947 :
Posted: Sat Apr 05, 2014 10:57 am
by swziy123
Question is "Which line contains a valid constructor in the following class definition?"
and line:
public TestClass getInstance() { return new TestClass(); }
CONTAINS valid constructor, because new TestClass() is a valid default constructor. Question sentence is misleading.
Re: About Question enthuware.ocajp.i.v7.2.947 :
Posted: Sat Apr 05, 2014 11:14 am
by admin
The sentence is correct. new TestClass(); is not a constructor, it is an invocation of a constructor.