• Post Reply Bookmark Topic Watch Topic
  • New Topic

over ridding in JAVA  RSS feed

 
Pavithra Praveen
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Here i have two classes NSJSPHostConfig.java and HostConfig.java, HostConfig.java is the super class and NSJSPHostConfig.java is the subclass.

intiall code flow will come to 'deployDescriptors' method of HostConfig.java, then it(deployDescriptors method) calls 'deployDescriptor' method, which is defined both in HostConfig.java and NSJSPHostConfig.java. Once the deployDescriptor method is called flow goes to deployDescriptor method of NSJSPHostConfig.java, how it can be possible?.
Any Idea about it, please let me know.

Regards,
Pavithra.
 
Soni Agrawal
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in this case my be this will be cause of overriding..i want how you are defining the object on which You are calling that function"deploDescriptor"
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand your question, you will need to create an instance of the subclass (so that at runtime the subclass method is invoked) but upcast the reference to the superclass (so that you can call the first method). That is, something like...

HostConfig hostConfig = new NSJSPHostConfig();
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!