• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

This and super keyword query

 
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i wish to know in how many ways can these two keywords be used :
this and super keyword
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 525
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ... ...
 
reply
    Bookmark Topic Watch Topic
  • New Topic