Why output is changed only for t2.y, but not for t2.x?
public class Test { int x=10; static int y=20; public static void main(String[] args) { Test t1=new Test(); t1.x=888; t1.y=999; Test t2=new Test(); System.out.println(t2.x+"---"+t2.y);//10---999 } } //instance variable /* If the value of a variable is varied from object to object such type of variables are called instance variables. For every object a separate copy of instance variables will be created. */ //static variable /* If the value of a variable is not varied from object to object such type variables is not recommended to declare as instance variables. We have to declare such type of variables at class level by using static modifier. In the case of instance variables for every object a separate copy will be created but in the case of static variables for entire class only one copy will be created and shared by every object of that class. */