aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes interface variable must be initialized ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "interface variable must be initialized ?" Watch "interface variable must be initialized ?" New topic
Author

interface variable must be initialized ?

Harikrishna Gorrepati
Ranch Hand

Joined: Sep 23, 2010
Posts: 422
interface P00_Constructor5_Ask
{
int answer; //The blank final field answer may not have been initialized..Why not taking default value ?
}


OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9322
    
  17

final fields don't get a default value, you have to assign them a value explicitly...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Harikrishna Gorrepati
Ranch Hand

Joined: Sep 23, 2010
Posts: 422
Got it..thanks Ankit
Arjun Srivastava
Ranch Hand

Joined: Jun 23, 2010
Posts: 432

final variables must be initialize on the same line or at the end of constructor.
because interface cannot have constructors so final variables have to be initialize on the same line on which it is being declared.


SCJP 6 | FB : Java Certifications-Help. | India Against Corruption
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: interface variable must be initialized ?