InterviewSolution
| 1. |
What are the types of Class Variables? |
|
Answer» We have THREE DIFFERENT types of Class VARIABLES in OOPs. 1. LOCAL VariablesThese types of variables are declared locally in methods, BLOCKS, and constructors. These variables are created when program control enters the methods, blocks, and constructor and are destroyed once program control leaves them. 2. Instance VariablesThese variables are declared outside a block, constructor, or method. These are created once a class object is created and destroyed when the object is destroyed. 3. Static VariablesStatic variables are also called class variables and are defined using the static keyword. These are declared within a class but outside a code block and a method. The creation of these variables starts when the program starts and is destroyed when the program ends. |
|