Pregunta de entrevista de Deloitte

Can we use the static variables inside static methods?

Respuestas de entrevistas

Anónimo

10 feb 2022

There are some rules : A local variable can not be static : class test { static int a = 10; static void m1() { static int b=20; // this line will give error , because local variable can not be static . System.out.println(a); // this will give outpur 10. } }

1

Anónimo

6 abr 2021

You cannot use static variable in the static method because JVM tries to allocate space for the static variable which he already allocated to the method inside which the static variable is declared.

17