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.
			
			
									
									
						About Question enthuware.ocajp.i.v7.2.947 :
Moderator: admin
		Online		
						
						
		
				
		
		
	- 
				admin
 - Site Admin
 - Posts: 10443
 - Joined: Fri Sep 10, 2010 9:26 pm
 - Contact:
 
Re: About Question enthuware.ocajp.i.v7.2.947 :
You can't start a method or constructor with ~. It will not compile because of that as well.
			
			
									
									
						- 
				The_Nick
 
Re: About Question enthuware.ocajp.i.v7.2.947 :
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
			
			
									
									
						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
		Online		
						
						
		
				
		
		
	- 
				admin
 - Site Admin
 - Posts: 10443
 - Joined: Fri Sep 10, 2010 9:26 pm
 - Contact:
 
Re: About Question enthuware.ocajp.i.v7.2.947 :
You may want to check this out: http://docs.oracle.com/javase/specs/jls ... ml#jls-3.8
			
			
									
									
						- 
				swziy123
 - Posts: 1
 - Joined: Sat Apr 05, 2014 10:54 am
 - Contact:
 
Re: About Question enthuware.ocajp.i.v7.2.947 :
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.
			
			
									
									
						and line:
public TestClass getInstance() { return new TestClass(); }
CONTAINS valid constructor, because new TestClass() is a valid default constructor. Question sentence is misleading.
		Online		
						
						
		
				
		
		
	- 
				admin
 - Site Admin
 - Posts: 10443
 - Joined: Fri Sep 10, 2010 9:26 pm
 - Contact:
 
Re: About Question enthuware.ocajp.i.v7.2.947 :
The sentence is correct. new TestClass(); is not a constructor, it is an invocation of a constructor.
			
			
									
									
						Who is online
Users browsing this forum: No registered users and 11 guests