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 member instance variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "member instance variables" Watch "member instance variables" New topic
Author

member instance variables

Gouri SenSharma
Ranch Hand

Joined: Apr 16, 2008
Posts: 57
What is the exact definition of member instance variables?
I ask this question as the Java round up game had a question.

Do member instance variables always get a default value if left unassigned.

Now I know that is TRUE for all instance variables except ones that are marked final.
I have noticed that if you have a final instance variable and if you DONOT assign an explicit
value to it before the constructor completes, a varaible not initialized exception is thrown.

So, keeping the above fact in mind I answered FALSE.

But the round up game counted this as a wrong answer.

Where is my understanding wrong..can somebody correct me???
Gouri SenSharma
Ranch Hand

Joined: Apr 16, 2008
Posts: 57
Sorry there were typos in the earlier post..so reposting...

What is the exact definition of member instance variables?
I ask this question as the Java round up game had a question.
Do member instance variables always get a default value if left unassigned. ?

Now I know that is TRUE for all instance variables except ones that are marked final.
I have noticed that if you have a final instance variable and if you DONOT assign an explicit
value to it before the constructor completes, a varaible not initialized exception is thrown.

So, keeping the above fact in mind I answered FALSE.

But the round up game counted this as a wrong answer.

Where is my understanding wrong..can somebody correct me???
Bob Wheeler
Ranch Hand

Joined: Apr 24, 2009
Posts: 317
Hi Anu,

Where is my understanding wrong..can somebody correct me???

I'm with you. I don't think your understanding is wrong.
So what are member instance variables? First of all, there are members (methods and variables).
Each of them can have member modifiers like (static, final, whatsoever). The same is true for
member variables (e.g static and instance). So member instance variables can be final. And as you stated correctly
these final variables HAVE TO be assigned (JLS)
I guess, this is a mistake.

cheers
Bob


SCJP 6 - SCJD - SCWCD 5 - SCBCD 5
JavaEnterpriseEditionFaq - TomcatFaq
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: member instance variables