Computer Science, asked by bhavik123, 1 year ago

what is meant my local variable and class variable with an example plz fast i will mark it as brainliest

Answers

Answered by sukhdeep1440p2rbs3
0
a variable for one sprite is local variable
a variable for all sprite is class variable or global variable
Answered by siddhartharao77
1
In Java:

Local Variables:

(1) Local variables are declared within a method. It cannot be used outside of that method.

Ex:

if(a > 100)
{
String a="Name";


Here You cannot use a outside of that if block.


(2) These are not initialized by JVM. It must be initialized by you before you try to use it.




Class Variables:

(1) Class variables are declared within a class but outside of a method.Must be declared static.

Ex:

Class Demo
{
static int hello;
}


(2) Initialized by JVM.


Hope this helps!
Similar questions