OCPJP 6 86%
Nikhil Sagar wrote:
Why You.i and Me.i Pointing to the same variable I.
Sccot Smith wrote:Because the subclass named Me inherited the parent class named You and won the variables i
But you should notice that the variable is saved in Heap Memory in JVM.
In Stack Memory,You and Me is point to the same piece of memory in Heap Memory.
Jeff Verdegan wrote:
Sccot Smith wrote:Because the subclass named Me inherited the parent class named You and won the variables i
But you should notice that the variable is saved in Heap Memory in JVM.
In Stack Memory,You and Me is point to the same piece of memory in Heap Memory.
Please don't post meaningless responses when you don't understand the principles at hand.
Thanks!
Sccot Smith wrote:
Jeff Verdegan wrote:
Sccot Smith wrote:Because the subclass named Me inherited the parent class named You and won the variables i
But you should notice that the variable is saved in Heap Memory in JVM.
In Stack Memory,You and Me is point to the same piece of memory in Heap Memory.
Please don't post meaningless responses when you don't understand the principles at hand.
Thanks!
Everyone is entitled to his own opinion,you are not god,you have no right to tell me how to do。
Jeff Verdegan wrote:
Sccot Smith wrote:
Jeff Verdegan wrote:
Sccot Smith wrote:Because the subclass named Me inherited the parent class named You and won the variables i
But you should notice that the variable is saved in Heap Memory in JVM.
In Stack Memory,You and Me is point to the same piece of memory in Heap Memory.
Please don't post meaningless responses when you don't understand the principles at hand.
Thanks!
Everyone is entitled to his own opinion,you are not god,you have no right to tell me how to do。
I am not trying to deny your opinion, nor am I trying to play god. I am simply asking you not to post views that you are unsure or only guessing about, out of respect for the people whose questions you are trying to answer.
If you thing your response is accurate, please provide support for your position.
Jeff Verdegan wrote:
Because there's only one i variable declared. The child class inherits it, but it's still just one variable.
OCPJP 6 86%
Nikhil Sagar wrote:
Jeff Verdegan wrote:
Because there's only one i variable declared. The child class inherits it, but it's still just one variable.
if the child class inherits somthing .Don't you think ,child class should have it's own copy Sir.
Jeff Verdegan wrote:
Nikhil Sagar wrote:
Jeff Verdegan wrote:
Because there's only one i variable declared. The child class inherits it, but it's still just one variable.
if the child class inherits somthing .Don't you think ,child class should have it's own copy Sir.
No, that's not what inheritance means. And your own observations show that.
OCPJP 6 86%
Nikhil Sagar wrote:
Jeff Verdegan wrote:
Nikhil Sagar wrote:
Jeff Verdegan wrote:
Because there's only one i variable declared. The child class inherits it, but it's still just one variable.
if the child class inherits somthing .Don't you think ,child class should have it's own copy Sir.
No, that's not what inheritance means. And your own observations show that.
Sir, You mean In Inheritance Child Class Does not have its own copy of Variables ??
Right??
Jeff Verdegan wrote:
Nikhil Sagar wrote:
Jeff Verdegan wrote:
Nikhil Sagar wrote:
Jeff Verdegan wrote:
Because there's only one i variable declared. The child class inherits it, but it's still just one variable.
if the child class inherits somthing .Don't you think ,child class should have it's own copy Sir.
No, that's not what inheritance means. And your own observations show that.
Sir, You mean In Inheritance Child Class Does not have its own copy of Variables ??
Right??
I thought that would be obvious by now, but, yes, that's correct.
OCPJP 6 86%
Nikhil Sagar wrote:
Jeff Verdegan wrote:
Nikhil Sagar wrote:
Sir, You mean In Inheritance Child Class Does not have its own copy of Variables ??
Right??
I thought that would be obvious by now, but, yes, that's correct.
Alright ,Let me think Sir then i will reply just in 10 minutes.
Nikhil Sagar wrote:
Jeff Verdegan wrote:
Nikhil Sagar wrote:
Jeff Verdegan wrote:
Nikhil Sagar wrote:
Jeff Verdegan wrote:
Because there's only one i variable declared. The child class inherits it, but it's still just one variable.
if the child class inherits somthing .Don't you think ,child class should have it's own copy Sir.
No, that's not what inheritance means. And your own observations show that.
Sir, You mean In Inheritance Child Class Does not have its own copy of Variables ??
Right??
I thought that would be obvious by now, but, yes, that's correct.
Alright ,Let me think Sir then i will reply just in 10 minutes.
OCPJP 6 86%
OCPJP 6 86%
Nikhil Sagar wrote:I don't THiNK so......
Have a look at this then tell me CHILD CLASS DOES NOT HAVE ITS OWN COPY OF VARIABLES ,Sir.
I THINK AT run time the object of child class has its own copy of variables of both classes But We know that object always has the copy of those instance variables who are present in its class So, its a very confusing situation here Because You said that child class does not have copy of the variables of its parent class or the all parent classes into the hierarchy over itself. So, According to me Your Point is also True but only in the case of STATIC variables, Because there is no second copy of static variable available to use AND this is the first reason.Second is we call Static variables as class variables because they belongs to only that particular class only neither to any object nor to any other class.
Correct me if i am wrong.
Nikhil Sagar wrote:
I don't THiNK so......
Have a look at this ..............
OCPJP 6 86%
Nikhil Sagar wrote:
I don't THiNK so......
Have a look at this then tell me CHILD CLASS DOES NOT HAVE ITS OWN COPY OF VARIABLES ,Sir.
I THINK AT run time the object of child class has its own copy of variables of both classes
But We know that object always has the copy of those instance variables who are present in its class
So, its a very confusing situation here Because You said that child class does not have copy of the variables of its parent class or the all parent classes into the hierarchy over itself.
So, According to me Your Point is also True but only in the case of STATIC variables,
Nikhil Sagar wrote:if variable i only present in the child class like my first code then why not this code is behaving just like the first one, Sir.
I mean why not both i pointing to the same variable i. If you are going to answer me something like "Because bothe belongs to different objects" then my ques will be like "if child class does not have its own copy and variable i is only present in the child class (but not have any copy) then all object of child class should have same values as it has into the parent class." i mean if i change the value into the parent class then this should also change into the all objects of the child class.
Nikhil Sagar wrote:If you are going to answer me something like "Because bothe belongs to different objects" then my ques will be like "if child class does not have its own copy and variable i is only present in the child class (but not have any copy) then all object of child class should have same values as it has into the parent class."
OCPJP 6 86%
Jeff Verdegan wrote:I'm glad you got it. To test your new found understanding, you can see if you can correctly predict the output of this program, and then run it to see if you were correct.
Nikhil Sagar wrote:
Jeff Verdegan wrote:I'm glad you got it. To test your new found understanding, you can see if you can correctly predict the output of this program, and then run it to see if you were correct.
Well thanks for this Wonderful Example.....