GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  Core Java
Go To First  |  Previous Question  |  Next Question 
 Core Java  |  Question 240 of 493    Print  
Scope Variables

  
Total Answers and Comments: 1 Last Update: June 11, 2006     Asked by: sudhakar_bvr 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
June 11, 2006 00:36:53   #1  
satyarajasekhar        

RE: Scope Variables

A variable's scope is the region of a program within which the variable can be referred to by its simple name.

The location of the variable declaration within your program establishes its scope and places it into one of these four categories:

 1) Member variable - A member variable is a member of a class or an object. It is declared within a class but outside of any method or constructor. A member variable's scope is the entire declaration of the class. However, the declaration of a member needs to appear before it is used when the use is in a member initialization expression.

 2) Local variable -You declare local variables within a block of code. In general, the scope of a local variable extends from its declaration to the end of the code block in which it was declared.

 3)Method parameter - Parameters are formal arguments to methods or constructors and are used to pass values into methods and constructors. The scope of a parameter is the entire method or constructor for which it is a parameter.

 4) Exception handler parameter - Exception-handler parameters are similar to parameters but are arguments to an exception handler rather than to a method or a constructor. The scope of an exception-handler parameter is the code block between { and } that follow a catch statement.


 
Is this answer useful? Yes | No

 Related Questions

How can I swap two variables without using a third variable?Can u plz tell me the logic behind it..?
Read Answers (7) | Asked by : RamaKrishna

we can compare two Strings with (==) when we assign some string value to the String variable,but if we create an object to that strings and compare eachother we cant use(==) operator ,because we can compare 
Latest Answer : Both == and equals() can be used to compare objects but in different aspects== is used to check whether the references are aliases.equals() is used to check for object value equality. equals() method in the object returns true only if the two references ...
Read Answers (4) | Asked by : venkat

1)what happens if i do this=null?2)how to swap 2 variables without using third temp variable in java?3)constructors can not be inherited,why?

Latest Answer : A variable's scope is the region of a program within which the variable can be referred to by its simple name. The location of the variable declaration within your program establishes its scope and places it into one of these four categories:  1) ...

Latest Answer : first of all declare a memory block according to data typeassign var nameinitite by def valuewassign orignal value ...
Read Answers (3) | Asked by : Raju

Latest Answer : yes, we can declare and they would be local to the block.Here is an example.....class Test {    public static void main(String[] args)     {        int i = 0;        ...

Latest Answer : We can access only static variables inside inner static class ...
Read Answers (3) | Asked by : Shankargouda Patil

Latest Answer : Local variables (including formal parameters) are visible only in the method, constructor, or block in which they are declared. Access modifiers (private, public, ...) can not be used with local variables. All local variables are effectively private ...
Read Answers (7) | Asked by : naggeek

the Color class contains some color names as constant variables . but it is twice. what for it.it have two variables like RED and red. what for it. i know that one is for set and get Color.but how the 
Latest Answer : Yes. It is using for IGNORING case. ...


 Sponsored Links

 
Related Articles

Service Oriented Java Business Integration Review

Service Oriented Java Business Integration Review Introduction If you ve read through the texts which give you an introduction to SOA or Web Services you will often find them to be quite frustrating and the reason for this is because they spend too much time referencing business processes which are
 

ODP.NET - Working with Bind Variables together with OracleParameter

ODP NET Working with Bind Variables together with OracleParameter With the help of OracleParameter you can include bind variables within any SQL statement These bind variables are nothing but run time query parameters The values in the SQL statement are bound at run time when we use bind variables m
 

Microsoft AJAX Library - Functions as Variables

Functions as Variables In JavaScript functions are first class objects This means that a function is regarded as a data type whose values can be saved in local variables passed as parameters and so on For example when defining a function you can assign it to a variable and then call the function thr
 

Java and Client Server Models

Java and Client Server Models The Role of Client Servers on the Web Client server models provide the essential mechanisms for working with the Internet In fact most of the World Wide Web is built according to this paradigm In client server models the web browsers run by millions of users are the cli
 

Swap two variables

How to swap two variables without using third variable? A variable is a named location in memory that is used to store data which can be modified in a program. Let us learn how to swap two variables without using third variable. This can be done in number of ways By using arithmetic operators
 

The Interview Snafu

How to turn someone else’s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won’t get over the line without a polished, prof
 

Using UML with Java

Using UML with Java While Java is not a new language its application for the development of embedded systems is quite new Developers are beginning to take a second look at modeling languages such as UML and many feel it can be a powerful tool in their development arsenal mosgoogle center Introductio
 

Importance of Proper English during Job Interview

Importance of Proper English during Job Interview Your job interview is crucially important and it will determine whether or not you will get the job Depending on the type of job you re going for it is very important for you to use proper English In most cases jobs which offer higher salaries will h
 

Java Technology Trends

Technology Trends Involving Java Java is an object oriented programming language OOP for Web browsers It is organized around data rather than actions and supports polymorphism which allows the same code to be written generically so it can function with different datatypes inheritance which allows on
 





About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape