Forums Register Login

This and super keyword query

+Pie Number of slices to send: Send
i wish to know in how many ways can these two keywords be used :
this and super keyword
+Pie Number of slices to send: Send
I'm not really sure what you want to ask here, but this and super can be used to call constructors, methods and fields of current class and super class respectively...
+Pie Number of slices to send: Send
Java key word 'this' always refers to the current object, like; this.doSomething() for
a method, or this.myRefVar for a member variable. The presence of 'this' is often
inferred by the compiler, as doSomething() and this.doSomething() mean the same
thing. Also, 'this' is often used within a constructor to invoke a different constructor,
as in; this(parm1, parm2, etc). The specific constructor invoked is based on matching
up the constructor and call parameter types. Key word 'super' is used in the same ways,
but refers to constructors, methods and member variables not in the current object, but
rather, above it in the inheritance tree. Does this help?

Jim ... ...
The longest recorded flight time of a chicken is 13 seconds. But that was done without this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 864 times.
Similar Threads
constructer
Problems in Inheritence
java
in simple servlet ,why a constructor has super()?.
regarding subclassing
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 07:29:29.