A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
This Site
»
Ranch Office
Author
Java - Overloading and Overriding of methods
Paras Shah
Greenhorn
Joined: Jul 24, 2001
Posts: 3
posted
Jul 24, 2001 16:59:00
0
Below is the code
<font size=+0> class Base { int i; Base() { System.out.println("Inside Base func"); add(1); } void add(int v){ System.out.println("Inside Base:Add func " + v); i += v; } void print(){ System.out.println(i); } } class Extension extends Base { Extension() { System.out.println("Inside Extension func"); add(2); } void add(int v){ System.out.println("Inside Extension:Add func " + v); i += v * 2; System.out.println("Inside Extension func:Value of i " + i); } } public class test { public static void main(String[] args) { System.out.println("Before"); bogo(new Extension()); } static void bogo(Base b) { b.add(8); b.print(); } }</font>
The output is 22.
What is the flow of this program ??
[This message has been edited by Marilyn deQueiroz (edited July 24, 2001).]
Marilyn de Queiroz
Sheriff
Joined: Jul 22, 2000
Posts: 9033
10
posted
Jul 24, 2001 18:47:00
0
moved to Java in General (beginning)
JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
I agree. Here's the link:
http://aspose.com/file-tools
subject: Java - Overloading and Overriding of methods
Similar Threads
Khalid question...
mughal question,need help
Constructor Problem
Khalid Mock - Constructor Evaluation
Java - Overloading and Overriding of methods
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter