/* Initializing variables serves several key purposes. It makes your code safer, guarantees a defined state at the start of the program’s execution, and can help avoid undefined behavior that can lead to bugs or crashes. */ class Example1 { int x=5; static int y; void m1(){ x=x+1; //print x; } static void m2(){y=y+1; //print y} public static void main(String[] args){ Example1 e = new Example1(); Example1 e1 = new Example1() e.m2() //y=1; e.m1(); // x=6 e1.m2() // y=2; e1.m1(); //x=6 } }