Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

On Forward Reference

 
Karthik Balasubramanian
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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.
Karthik
 
James Hook
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic