Help ! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
11th Jul 2020, 8:04 AM
๐Ÿ’•๐Ÿ’ž๐Ÿ’•Neelam๐Ÿ’•๐Ÿ’ž๐Ÿ’•
5 Answers
+ 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
11th Jul 2020, 6:10 PM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 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); } }
11th Jul 2020, 12:05 PM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 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"
11th Jul 2020, 12:29 PM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 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 โ˜น๏ธโ˜น๏ธโ˜น๏ธ๐Ÿ˜ถ๐Ÿ˜ถ
11th Jul 2020, 4:55 PM
๐Ÿ’•๐Ÿ’ž๐Ÿ’•Neelam๐Ÿ’•๐Ÿ’ž๐Ÿ’•
0
Oh yes ๐Ÿ˜… Tq......
12th Jul 2020, 4:00 AM
๐Ÿ’•๐Ÿ’ž๐Ÿ’•Neelam๐Ÿ’•๐Ÿ’ž๐Ÿ’•