5 Respuestas
+ 2
Neelam Padhy
Same mistake that you declare abtract method callBack(int param) ; small c.
But implementing CallBack(int p) ; here taking Capital C. Won't matching. So Error.
Edit:
https://code.sololearn.com/cwEm34Ox07Dj/?ref=app
+ 1
//corrected code, just changes, read comments added
interface CallBack
{
//declaration of abstract method
void callBack(int param); //abstract method
}
public class Client implements CallBack
{
public void callBack(int p) //small c in name as you taken small c in function name as in interface..
//defination of abstract method
{
System.out.println("callBack called with "+p);
}
public void nonInterfaceMethod()
{
System.out.println("I m interface method");
}
}
class Interface Demo //remove public.
{
public static void main(String[] args) {
CallBack c = new Client();
c.callBack(43);
}
}
+ 1
Not able to reply answer via DM.
public abstract int callBack(int param); //abstract method
For the above abstract method, implementation is:
public class Client implements CallBack
{
public int callBack(int p)
{
System.out.println("callBack called with "+p);
return 1;// Return an int value
//you changed abstract method return type to int so implementation also should return an int value like this.
}
And not allowed space in names so
"interface demo" change to like "interface_demo"
+ 1
interface CallBack
{
//declaration of abstract method
public abstract int callBack(int param);
//abstract method
}
public class Client implements_CallBack
{
public int CallBack(int p)
//defination of abstract method
{
System.out.println("callBack called with "+p);
return 1;//return value should be an int value bcoz there is a change on abstract method return type to int...
}
int nonInterfaceMethod()
{
System.out.println("I m interface method");
}
}
public class Interface_Demo
{
public static void main(String[] args) {
CallBack c = new Client();
c.callBack(43);
}
}
What the problem again I m not able to find out ☹️☹️☹️😶😶
0
Oh yes 😅
Tq......