interface A {
void a();
}
public class B implements A{
public void a(){
System.out.println ("Output");
}
public void b(){
System.out.println ("Output");
}
}
public class Hd{
public static void main(String []args){
A test = new B();
test.a();
B test1 =B(A)
test.b();
}
}
in class hd call voida() in class B of interface A And if class B's void b() call is correct, If you are going to do it in the same java file, you should erase the public in front of class B Now, below I think B test1 = B(A) semicolon is missing? I can't take out the semicolon, so I changed the coding interface A { void a(); }
class B implements A{
public void a(){
System.out.println ("Output a()call");
}
public void b(){
System.out.println ("Output b()call");
}
}
public class Hd{ public static void main(String []args){ A test = new B(); test.a(); System.out.println ("Let's move on"); B test1 =new B(); test1.b();
}
}
It's working like this
© 2024 OneMinuteCode. All rights reserved.