Meaningless Drivel is fun!*
The moose likes Associate Certification (SCJA,OCAJ 5/6) and the fly likes Doubt with cert objective - accessing object fields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Associate Certification (SCJA,OCAJ 5/6)
Bookmark "Doubt with cert objective - accessing object fields" Watch "Doubt with cert objective - accessing object fields" New topic
Author

Doubt with cert objective - accessing object fields

Andy James
Ranch Hand

Joined: Aug 22, 2005
Posts: 90
Hey Ranchers,

Are the object fields same as instance variables?

For example, in the following class, which is an object field - name or myName?



Are the field names derived from the exact names of the instance variable or from the method names?

Cheers
Andy
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1012
    
    5

myName is an instance variable here. Nothing is derived although modern IDEs can generate setter and getter methods based upon the names of instance variables.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5216
    
  12

That's a class that won't compile, because name is not an existing parameter.

myName is the instance variable (or object field as you like)
value is the parameter

In real world, you have something like this:


And then as James already mentioned you let your IDE generate the necessary getters and setters (it's a lot faster than typing them yourself). So you'll end up with this class:


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt with cert objective - accessing object fields