This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Now my question is i have assigned the values also to the fields but then why the results are 0 and null ?
i have created the object of parent class and assigned the values also. Now i have created another object of its subclass and trying to print those values. Don't you think that it should print because the parent class now has values assigned to their fields in it.
please explain me in detail as i'm a beginner and want to clear my foundation base in java very seriously.
thanks in advance.
Vinod Kumar Nair
"Any fool can write code that a computer can understan. Good programmers write code that humans can understand."
You created an instance of an Employee and EmpInfo. EmpInfo is an Employee. You populated the object of Employee but not the object of EmpInfo. You then printed empInfo which was never populated.
Maybe what needs to be done is Employee should have EmpInfo instead of inhereting from it.