Why do member variables have default values whereas local variables don't have any default value?
Question
Why do member variables have default values whereas local variables don’t have any default value?
Answer
member variable are loaded into heap, so they are initialized with default values when an instance of a class is created. In case of local variables, they are stored in stack until they are being used.