The initialization order is matter here.
- Set fields to default initial values (0, false, null)
- Call the constructor for the object (but don't execute the body of the constructor yet)
- Invoke the constructor of the superclass
- Initialize fields using initializers and initialization blocks
- Execute the body of the constructor
So, first case will be initialize the variable sample_attribute
in 4th step, second will initialize the variable sample_attribute
in 5th step. It's all depends on your requirement.
If you want to access any of the variables from Constructor, you need to use 1st case.