3B. Java Basics for Selenium - Java Variables - Interview Questions - Part 2

preview_player
Показать описание
Explain where variables are created in memory?
Method Area: It stores all the class code, method code and class variables declared.
Heap Memory: It stores all the objects created.
JVM stack Area: It stores the information of methods at run time. For example, the method variables initiated at run time.

What is final variable?
If a variable is declared as final variable, then you can not change its value. It becomes constant.

How to define a constant variable in Java?
The variable should be declared as static and final. So only one copy of the variable exists for all instances of the class and the value can't be changed also.

static final int MAX_LENGTH = 50; is an example for constant.
Рекомендации по теме