Small program ; interface need help!! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

Small program ; interface need help!!

Create a small program that will utilize the interface. note that a class will implements an interface. ANY SUGGESTIONS?

17th Sep 2020, 6:52 AM
Charlene Allysa Razon
Charlene Allysa Razon - avatar
8 Answers
+ 3
I have seen this example many times: Create an interface `Shape` with members height, width. Declare an abstract method `area()` implement `Shape` in `Reactangle` and `Triangle` classes , both of these will have their own implementation of `area()` method. Edit: Going ahead, You can create objects of concrete classes (Rectangle, Triangle) and reference them through Base type (interface) to show polymorphic magic 😁. Try to do it yourself. If you get errors feel free to ask here.
17th Sep 2020, 7:07 AM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 1
I dont think i can but someone else could help you if u especify what language and interface between what. Again Im a newbie idk what this is about. 😖😖
17th Sep 2020, 7:04 AM
Arturop
Arturop - avatar
+ 1
same
17th Sep 2020, 7:04 AM
Charlene Allysa Razon
Charlene Allysa Razon - avatar
+ 1
Please show us your try first before asking us for the solution. It makes me feel like you're giving us your assignment.
18th Sep 2020, 3:27 PM
Query
Query - avatar
0
Im not able to understand the question. 😥
17th Sep 2020, 6:58 AM
Arturop
Arturop - avatar
0
Create an interface Animal and declare a void sound() method. Now create a class Dog which implements Animal. You must now give implementation to the void sound() method. Inside that you can write something like "Dog barks". Now create an instance of this class in the main method and invoke the sound() method on it.
17th Sep 2020, 7:08 AM
Avinesh
Avinesh - avatar
0
thank you guys! ☺️
17th Sep 2020, 7:09 AM
Charlene Allysa Razon
Charlene Allysa Razon - avatar
- 1
can you suggest me a small program using interface
17th Sep 2020, 7:00 AM
Charlene Allysa Razon
Charlene Allysa Razon - avatar