- 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?
9 ответов
+ 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.
+ 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. 😖😖
+ 1
same
+ 1
Please show us your try first before asking us for the solution. It makes me feel like you're giving us your assignment.
0
Im not able to understand the question. 😥
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.
0
thank you guys! ☺️
- 1
can you suggest me a small program using interface