wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Please explain the output of code below Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Please explain the output of code below" Watch "Please explain the output of code below" New topic
Author

Please explain the output of code below

Shaveta Chawla
Greenhorn

Joined: Aug 01, 2007
Posts: 13
What will be the output of the following code? Can I get some detail explanation?

class A{
void show(){
System.out.println("A");
}
}

interface my{
public void show();
}

class B extends A{
B(my m){
m.show();
}
public void show(){
System.out.println("B");
}
}

public class test implements my{
public void show(){
System.out.println("test");
}
public static void main(String args[]){
test t=new test();
B b=new B(t);

b.show();


}


}

Thanks
bart zagers
Ranch Hand

Joined: Feb 05, 2003
Posts: 234
Did you run it?
What was the result and what did you expect instead?
Shaveta Chawla
Greenhorn

Joined: Aug 01, 2007
Posts: 13
the output was

test
B
bart zagers
Ranch Hand

Joined: Feb 05, 2003
Posts: 234
Originally posted by Shaveta Chawla:
the output was

test
B


ok, and what did you expect, or which part do you not understand?
Shaveta Chawla
Greenhorn

Joined: Aug 01, 2007
Posts: 13
Oh i understood now actually i got confused. Actually i made the same design with Threads n i got confused with the run method

thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please explain the output of code below