Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes local variable 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 » Programmer Certification (SCJP/OCPJP)
Bookmark "local variable" Watch "local variable" New topic
Author

local variable

rengarajan vaikuntam
Ranch Hand

Joined: Oct 04, 2004
Posts: 37
Can we say a variable declared inside a try block as a local variable?

Pls can someone explain.
Thanks.
Mikalai Zaikin
Ranch Hand

Joined: Jun 04, 2002
Posts: 3204
    
    5
Variables can be:

1. "class variable" - static variable declared in class scope, holds same value for all instances of the class
2. "instance variable" - variable declared in class scope and holds value unique to each instance.
3. "local variables" - variable declared inside method or any other block which defines (limits) visibility, like : a) method b) "for" loop declaration c) "catch" clause, etc ...

So, basically, you are right, and variable inside "try" block considered local variable.

regards,
MZ


Free SCDJWS 5.0 Study Guide - SCDJWS 5.0 Quiz (How to get SCDJWS 5.0 Quiz)
Java Platform, Enterprise Edition 6 Web Services Developer Certified Expert Exam Study Guide and Quiz
rengarajan vaikuntam
Ranch Hand

Joined: Oct 04, 2004
Posts: 37
Thanks Mikalai Zaikin
I have one more doubt
can we say, a class, whose constructors are all marked private, a final class.
Thamks
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by rengarajan vaikuntam:
Thanks Mikalai Zaikin
I have one more doubt
can we say, a class, whose constructors are all marked private, a final class.
Thamks


A class with only private constructors is implicitly final. As far as I know, such a class can not be successfully extended.


SCJP Tipline, etc.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: local variable