Java / Variable
1. Is it possible to access a non static variable in static context?
A static variable in Java is at class level and shared among all its instances. A static variable is initialized when the class is loaded by the JVM....
2. Is null, main, exit, delete are keywords in Java?
No.
3. Explain integer number with leading zeros in Java.
The number starting with 0 represents an octal digit.
4. What is transient variable in Java?
Transient variable cannot be serialized. For example if a variable is declared as transient in a class implementing Serializable interface and the class is persisted to an ObjectStream, the value of the variable is ignoerd and not written to the...
5. What is shadowing in Java?
Shadowing refers to the practice of using two variables with the same name within scopes that overlap. When shadowed, the variable with the higher-level scope is hidden because the variable with lower-level scope overrides it....
6. Different types of variables in Java.
Instance or non static variables, Static or class variables, Local or method variables, and parameters.
7. Difference between static type and dynamic type programming languages.
A language is statically typed if the type of a variable is known at compile time. For example in Java, C and C++, programmer must specify what type each variable is....
8. What are local variables in Java?
A local variable is one that exists inside a method or a block of code and exists as long as that method or block is executing. Once the program reaches the end of the method (or block), the local variable...
9. Is local variable thread safe in java?
Yes. All local variables defined in your program will be allocated memory in the stack....