in JAVA by
What do you understand by an instance variable and a local variable?

1 Answer

0 votes
Instance variables are those variables that are accessible by all the methods in the class. They are declared outside the methods and inside the class. These variables describe the properties of an object and remain bound to it at any cost.

All the objects of the class will have their copy of the variables for utilization. If any modification is done on these variables, then only that instance will be impacted by it, and all other class instances continue to remain unaffected.


class Athlete {

public String athleteName;

public double athleteSpeed;

public int athleteAge;


Local variables are those variables present within a block, function, or a constructor and can be accessed only inside them. The utilization of the variable is restricted to the block scope. Whenever a local variable is declared inside a method, the other class methods don’t have any knowledge about the local variable.


public void athlete() {

String athleteName;

double athleteSpeed;

int athleteAge;

Click here to read more about JAVA
Click here to read more about Insurance

Related questions

+2 votes
asked May 31, 2020 in JAVA by SakshiSharma
0 votes
asked Dec 20, 2019 in Service Discovery by sharadyadav1986
+1 vote
asked Feb 10, 2020 in R Language by rahuljain1
0 votes
asked Sep 22, 2020 in Artificial Intelligence by Robindeniel
0 votes
asked Sep 3, 2020 in Git by SakshiSharma