We have three different types of Class Variables in OOPs.

1. Local Variables

These 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 Variables

These 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 Variables

Static 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.

BY Best Interview Question ON 03 Nov 2021