Meaningless Drivel is fun!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes On Forward Reference 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 "On Forward Reference" Watch "On Forward Reference" New topic

On Forward Reference

Karthik Balasubramanian
Ranch Hand

Joined: Dec 13, 2002
Posts: 43
I am appearing for SCJP 2 1.4 Exam tomorrow. I do not have a good understanding on "Forward Reference on variables and methods".Can some one please explain me very brief.
James Hook

Joined: Jan 20, 2003
Posts: 18
the term 'forward reference' applies to using a method or variable before it has been declared. In c\c++, the compiler has to know the prototype of the method before it is used but Java is not so demanding.
The rules are:
Method Variables - you must declare and initialize a method variable before it is used
Class/Instance Variables/Methods - can be used in the source code file before they have been declared. The Java compiler will probably already know about these methods form a previous sweep through the file.
Good luck with your exam (if you haven't already taken it)
I agree. Here's the link:
subject: On Forward Reference
It's not a secret anymore!