File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 9291
    
  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
 
jQuery in Action, 2nd edition
 
subject: interface variable must be initialized ?
 
Similar Threads
4m Dan's Exam
Let's say that this question is about instantiation
Interface question from JQPlus
Question related to Interfaces
difference between abstract class and interface?