i heard that when we don't specify the constructor
compiler creates the default constructor which intializes
instance variables ...but in this example i created the constructor
and initialized variable a and i didn't initialize variable b..
when i invoke obj.b ..it gives 0 (default value) ..
so where b gets initialized....
No. When you declare a static or member variable, it will have this form:
<Type> <Name> = <Value>.
The value is assigned to the variable before any constructor or initializer is ran.
If you don't supply the = <Value> part, the compiler will more or less add it for you, setting the variable to 0, null, false, etc.