Results 1 to 2 of 2
- 11-06-2008, 04:59 PM #1
Member
- Join Date
- Nov 2008
- Posts
- 1
- Rep Power
- 0
the explanation of output of simple java program
class Base {
int i=99;
public void amethod(){
System.out.println("Base.amethod()");
}
}
public class RType extends Base{
int i=-1;
public static void main(String argv[]){
Base b = new RType();//<= Note the type
System.out.println(b.i);
b.amethod();
}
public void amethod(){
System.out.println("RType.amethod()");
}
}
I complied the above code and got the following output :
99
RType.amethod()
Can someone explain why I got 99 instead of -1 .
Thanks
Amol
- 11-06-2008, 05:06 PM #2
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 5
Similar Threads
-
how to record multiple input names and output later in program
By jbajwa1 in forum New To JavaReplies: 4Last Post: 10-02-2008, 10:05 PM -
Program can run but output all null
By matt_well in forum New To JavaReplies: 15Last Post: 07-24-2008, 08:48 AM -
Peculiarty in code of simple program...
By Kreuz14 in forum New To JavaReplies: 4Last Post: 01-23-2008, 03:27 AM -
help with simple program in java
By katie in forum New To JavaReplies: 2Last Post: 08-06-2007, 08:03 PM -
help with simple java program
By leonard in forum New To JavaReplies: 3Last Post: 07-30-2007, 09:40 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks