answersLogoWhite

0


Best Answer

hi friend....

Instance variable means with which you need to create an obeject in order to invoke any methods or variables defined in a class.

For ex:

class A

{

int a=10;

public void inc()

{return a++; }

}

To invoke a member

A b=new A();

b.inc();

System.out.println(b.a);

If incase of a static method you can directly call using class name itself.

like :

b=Math.sqrt(a);

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

An Instance variable is a variable that is attached to a class instance or object.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is mean by instance variable with example?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you create an static int as an instance variable?

You create a static integer as an instance variable by declaring it in a class using a statement that consists of the privacy level, then the keywords "static" and "int", and finally, the name of the variable. For example:public class TheAnswerIsHere {public static int example = 0;}will define an int example with initial value 0. The variable is accessed through the statement TheAnswerIsHere.example.


What does instance field mean in Java?

Fields defined without the "static" keyword.Their value is unique to each instance (object) of a class.AnswerInstance variable is a variable declared within the class for which every object of the class has its own value.


What is Variable Shadowing in Java?

In Java, there are three kinds of variables: local variables, instance variables, and class variables. Variables have their scopes. Different kinds of variables have different scopes. A variable is shadowed if there is another variable with the same name that is closer in scope. In other words, referring to the variable by name will use the one closest in scope, the one in the outer scope is shadowed.A Local Variable Shadows An Instance VariableInside a class method, when a local variable have the same name as one of the instance variable, the local variable shadows the instance variable inside the method block.


What is a structure variable in computer programming?

A structure variable is a name that refers to a data structure. For example: struct S {/*...*/}; int main (void) { S x; /* x is a structure variable that refers to an instance of the structure S */ // use x... return 0; }


What is the difference between the structure tag and structure variable?

The structure tag is a type. The structure variable is an instance of that type.

Related questions

What is a declaring variable?

Variable declaration is when you declare a variable. For example: String foo; The data type is String and now I can modify foo and don't need to type String again. It can be an instance variable or a local variable.


How do you create an static int as an instance variable?

You create a static integer as an instance variable by declaring it in a class using a statement that consists of the privacy level, then the keywords "static" and "int", and finally, the name of the variable. For example:public class TheAnswerIsHere {public static int example = 0;}will define an int example with initial value 0. The variable is accessed through the statement TheAnswerIsHere.example.


What are 10expressions which mean for example?

for example for instance for one thing ...


What is difference between an instance variable and a class variable?

An instance variable is typically associated with an object instance of the class whereas class variable is not associated with any object instance. Static variables are referred to as class variables while non-static regular variables are called instance variables. Simply put, you will have as many instances of the instance variable as there are object instances. i.e., if there are 10 instances of an object, you will have 10 instances of that instance variable as well. But, there will be only one instance of the static or class variable. Instance variables are accessed as follows: objname.variableName; Class variables are accessed as follows: ClassName.variableName;


What does instance field mean in Java?

Fields defined without the "static" keyword.Their value is unique to each instance (object) of a class.AnswerInstance variable is a variable declared within the class for which every object of the class has its own value.


What does Variables mean for a science project?

A variable means that something that you can change, measure, or keep the same. Example: Responding variable: The variable you can measure. Controlled variable: The variable you keep the same. Manipulated variable: The variable that you change.


What does instince mean?

An instance is an example or single occurrence of something:


What is Variable Shadowing in Java?

In Java, there are three kinds of variables: local variables, instance variables, and class variables. Variables have their scopes. Different kinds of variables have different scopes. A variable is shadowed if there is another variable with the same name that is closer in scope. In other words, referring to the variable by name will use the one closest in scope, the one in the outer scope is shadowed.A Local Variable Shadows An Instance VariableInside a class method, when a local variable have the same name as one of the instance variable, the local variable shadows the instance variable inside the method block.


Default value for instance variable?

Depending on the language you are using the default of an instance variable can be '0', 0, null, empty, '', or have a random number.


What is that mean excitement?

A variable that causes change in the output of a system. In a RC circuit, for example, the input V is the excitation variable


What other phrases also mean 'for example' or 'for instance'?

A couple of phrases that can be used like "for example" and "for instance" are among other things, and in other words.


What is another word for example?

Illustration, for instance, and case may all be used to mean example.