What is the output of this program?

class Variable5
{
static int x=10;
int y=20;
public static void main(String[] alt)
{
Variable5 v1=new Variable5();
v1.x=500;
v1.y=300;
Variable5 v2=new Variable5();
System.out.println(v2.x);
System.out.println(v2.y);
}
}
/*
Output:- 500 20
Explanation:- Instance variables are also known as object level variable and
static variables are also known as class level variables.
*/

0 comments: