dzem68
02-10-2002, 07:03 PM
Ok, I know this code i am about to post is not vb but I cant find a site even remotely close to this one to post it on. So I hope you will bare with me and offer some help....the help i am requesting is more logic related rather than code specific.
can you explain why the output from the following java code produces "Hello from B3" and not "Hello from C3".
class A3{
void hello(){
System.out.println("Hello from A3");
}
void hello(int i) {
System.out.println("Hello from A3 " + i);
}
}
class B3 extends A3{
void hello(){
System.out.println("Hello from B3");
}
}
class C3 extends B3{
void hello(String s){
System.out.println("Hello from C3 " + s);
}
}
class MethodOverriding3{
public static void main(String args[]){
A3 obj = new C3();
obj.hello();
}
}
thanks,
dz
can you explain why the output from the following java code produces "Hello from B3" and not "Hello from C3".
class A3{
void hello(){
System.out.println("Hello from A3");
}
void hello(int i) {
System.out.println("Hello from A3 " + i);
}
}
class B3 extends A3{
void hello(){
System.out.println("Hello from B3");
}
}
class C3 extends B3{
void hello(String s){
System.out.println("Hello from C3 " + s);
}
}
class MethodOverriding3{
public static void main(String args[]){
A3 obj = new C3();
obj.hello();
}
}
thanks,
dz