Multiple choice

Which of the following is true about the static member variable?

  1. It is initialized to 0 when the first object is created.

  2. It is visible outside the class also.

  3. Every time an object is created, it is initialized to 1.

  4. None of the above

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Static member variables are initialized to 0 when the first object of the class is created, and this initialization happens only once. They are shared among all objects of the class and retain their values between object creations. They are not re-initialized to 1 each time, and they are not visible outside the class unless declared public.