Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please explain the output of code below

 
Shaveta Chawla
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you run it?
What was the result and what did you expect instead?
 
Shaveta Chawla
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the output was

test
B
 
bart zagers
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic