aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes This and super keyword query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "This and super keyword query" Watch "This and super keyword query" New topic
Author

This and super keyword query

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

i wish to know in how many ways can these two keywords be used :
this and super keyword


OCPJP 6.0 93%
OCPJWCD 5.0 98%
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

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...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Jim Hoglund
Ranch Hand

Joined: Jan 09, 2008
Posts: 525
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 ... ...


BEE MBA PMP SCJP-6
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: This and super keyword query
 
Similar Threads
java
constructer
regarding subclassing
in simple servlet ,why a constructor has super()?.
Problems in Inheritence