• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

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: 9704
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 ... ...
 
My, my, aren't you a big fella. Here, have a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic