This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 3199
    
    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
 
Similar Threads
Why can a method local inner class access a final variable
static declaration in main
static-in interface
method local class- final vairable
static in a method