First of all, I am surprised that your code even compiles. I see several minor problems that *should* cause compiler errors. I assume this means that the code you posted here isn't exactly the same as the code you are compiling.
You should copy and paste your code, rather than type it, so that such inconsistencies are avoided.
With that siad, I would like to address the issue of your variable declarations. Although this isn't directly linked to your problem, the solution I propose will make your code much more readable.
It looks like each variable you use is only used within a single method. You should declare them in the method where they are used.
For one thing, this will guarantee that sumVal gets reset to zero every time you call sum(). Otherwise, it retains the value from the last time you called sum.
You should make similar changes with your other variables.
Then when you need the result of the sum() method, you use syntax similar to what I posted earlier. This probably will go in the main() method of the MyDriver class:
I think I'll stop there. If you still don't understand any of the details, please come back with more questions. Be sure to post any compiler errors you get along the way so we can help you fix those, too.
Keep coding!
Layne