Forums Register Login

Using super method while extending a class

+Pie Number of slices to send: Send
I want to get myself a clear understanding of how we use super method

I have one class call AdvSearchEx
i have one method in AdvsearchEx as public void onClickSearch(Button button, ArgumentList args)


Now i havw extended the class as following
--------------------------------------------------------------------------
public class AdvSearchEx extends com.documentum.webcomponent.library.advsearch.AdvSearchEx {
public void onClickSearch(Button button, ArgumentList args)
{
super.onClickSearch(button,args);
System.out.println("Reached Custom class!!");
}
--------------------------------------------------------------------------

Now onClickSearch it self calls some another method define in some another class

Now my question is that
when u execute the code and it reaches to super.onClickSearch will it complete processing (excuting ) every thing f that parent method (that is if parant method calls some xyz method in different class)

and then only the System.out.println(Reached custom class will be type) ?
+Pie Number of slices to send: Send
Have you tried executing it? What happened?

To see where the execution flow goes, add println()s to the code.
+Pie Number of slices to send: Send
yes i have tried

the problem is i am trying to understand the code and "onClickSearch method makes call to another method of some different class"

so according to my understanding of code i thought that System.out.println should be printed after that(onClickSearch method makes call to another method of some different class wherin also i havr typed some println system"

but it does not

May be my thinking is wrong

But generally super.onClickSearch(button,args);
should be excuted first (no mater if it call 100 methods)

just wanted to confirm that
+Pie Number of slices to send: Send
 

Originally posted by Raj kalaria:
yes i have tried

the problem is i am trying to understand the code and "onClickSearch method makes call to another method of some different class"

so according to my understanding of code i thought that System.out.println should be printed after that(onClickSearch method makes call to another method of some different class wherin also i havr typed some println system"

but it does not

May be my thinking is wrong

But generally super.onClickSearch(button,args);
should be excuted first (no mater if it call 100 methods)

just wanted to confirm that



I suggest you visit the SCJP forum and learn a few things about class initialization, and other stuff about how things work.

And, it would be more helpful if you tried this on a small dummy class, and later on the real ones. Don't try to eat the elephant in day, one bite at a time

If you want more help, paste all the code related and we're here to help you.
+Pie Number of slices to send: Send
I think we need some more code to help us understand what you are trying to do. Did you write all of these classes yourself? If so, please post the pertinent code so we can help you understand how it works.

I agree that println() calls will help you see which functions are called. I often add a single println() at the beginning of a method that prints the methods name (and sometimes the parameter values). If, as you say, the message is not printed, then that particular method isn't called. But like I said earlier, we need to see some more code in order to understand why this is happening.

Layen
I knew I would regret that burrito. But this tiny ad has never caused regrets:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 716 times.
Similar Threads
Certification Study Guide by Simon Roberts Philip Heller Micheal Ernst
polymorphism question
Overriding
mock Q29
classloader chain
More...

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