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  >  Java
Go To First  |  Previous Question  |  Next Question 
 Java  |  Question 121 of 921    Print  
What is the difference between static and non-static variables
A static variable is associated with the class as a whole rather than with specific instancesof a class. Non-static variables take on unique values with each object instance.


  
Total Answers and Comments: 2 Last Update: September 24, 2007   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
June 23, 2007 06:21:17   #1  
naveenkumarb        

RE: What is the difference between static and non-stat...
Instance variables can be accessed only by the Instance methods only.

Static variables can be accessed by any method(static or Instance methods)

 
Is this answer useful? Yes | No
September 24, 2007 04:10:42   #2  
snehlata        

RE: What is the difference between static and non-stat...
Static variables belongs to class only they have no relation to object. They allocate memory when class is loaded at run time. That's why we can call them by the name of class variables.
Non-static variables belongs to object. They allocate memory at compile time.

 
Is this answer useful? Yes | No

 Related Questions

A (non-local) inner class may be declared as public, protected, private, static, final, orabstract. 
Latest Answer : A non-static member class means inner class is a member of an enclosing class, it can have any accessiblity:public,default,protected, or private. ...

The >> operator carries the sign bit when shifting right. The >>> zero-fills bits that havebeen shifted out. 
Latest Answer : While dealing with (+)ve numbers there is no difference between >>> and >> operators.Both operators shift zeros into the upper bits of a number.The difference arises when dealing with (-)ve numbers.Since (-)ve numbers,(-)ve numbers have ...

When a task invokes its yield() method, it returns to the ready state. When a task invokesits sleep() method, it returns to the waiting state. 
Latest Answer : yield method is mainly used to release the lock of resource and pull up in to steady state from wait pool. Sleep() will pull the thread to sleep for the given time. It will throws exception while trying to intrupt in b/w the sleep state ...

Under preemptive scheduling, the highest priority task executes until it enters the waitingor dead states or a higher priority task comes into existence. Under time slicing, a taskexecutes for a predefined 
Latest Answer : 1.    Pre-emptive Scheduling.Ways for a thread to leave running state -·         It can cease to be ready to execute ( by calling a blocking i/o method)·         ...

The CheckboxMenuItem class extends the MenuItem class to support a menu item thatmay be checked or unchecked. 

If an expression involving the Boolean & operator is evaluated, both operands areevaluated. Then the & operator is applied to the operand. When an expression involvingthe && operator is evaluated, the 
Latest Answer : & -> for bitwise operation&&-> for logical comparison ...

A break statement results in the termination of the statement to which it applies (switch,for, do, or while). A continue statement is used to end the current loop iteration andreturn control to the loop 
Latest Answer : The break keyword halts the execution of the current loop and forces control out of the loop. The continue is similar to break, except that instead of halting the execution of the loop, it starts the next iteration. ...

A non-static inner class may have object instances that are associated with instances ofthe class's outer class. A static inner class does not have any object instances. 
Latest Answer : The static inner classes  can be accessed with out creating it's objects or we can  access  static inner classes with direct class name but in the case of  non-static inner classes access we have to create the object of that class. ...

String objects are constants. StringBuffer objects are not. 
Latest Answer : see the following line of codeclass abc{ public static void main(String args[]) {  String ab=new String("test");ab.replaceFirst("e","b");System.out.println(ab); }}guess what the result be No it will not replace e with b .Thats ...

The Frame class extends Window to define a main application window that can have amenu bar. 
Latest Answer : Frame can be part of the window but window can not part of the frame. like e.g. when you will create frames with the help of HTML at that time you see many frames in a one window but we can't make a window in frame so we can say fram is a part of ...


 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
 

C++ Static Functions

C Static Functions Static member functions have a class scope and they do not have access to the this pointer of the class When a member is declared as static a static member of class it has only one data for the entire class even though there are many objects created for the class The main usage of
 

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
 

What is difference between call by value and call by reference in function?

The arguments passed to function can be of two types 1. Values passed 2. Address passed The first type refers to call by value and the second type refers to call by reference. For instance consider program1 main() { int x=50, y=70; interchange(x,y); printf(“x=%d y=%d”,x,
 

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
 





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