Can we declare local variable as static?
Java interview Questions(2021)
No, we cannot declare local variable as static. If we declare local variable as static then we will get compile time error: illegal start of expression.
Actually, local variable gets memory allocation only if method is called.
But if we declared local variable as static then it should get the memory at the time of class loading.
This is violating the contract or rule, so it leads to compile time error.
#java
#javainterviewquestion
#localvariablejava If you want to help us for enlarging our channel, then please donate us by your own wish:
Paytm: 7509058785
Upi: 7509058785@ybl