+ 13

What is interface in java?why it has to be abstract? What is abstract?😨😨😨😨😨😨

confused in java coding now...thanks 😩😩😩😩😩😩

26th Oct 2017, 9:59 AM
Andrew Ting Mai Zau
Andrew Ting Mai Zau - avatar
3 ответов
+ 9
This is the explanation that I have for what abstract is: Abstract classes and methods are designed to be inherited. You don't actually make objects using an abstract class; think of an abstract class as a kind of interface, of which any and all subclasses have the same variables / methods. For example, you don't make objects of "Food" (abstract class), but you make objects of "Apple" and "Orange" (actual class), of which extend the "Food" class. Similarly, abstract methods are supposed to be inherited; it just denotes that any class that has inherited the abstract method has a method with a given name, return, and parameters, that is the abstract method. How they implement the method can vary, which is why there is no body to an abstract method. It is just meant to denote that the class has a method with a specific name, return, and parameters. If abstract makes sense to you, just think if an interface as a kind of reference guide. Any classes that have implemented an interface will have inherited all the methods in the interface. However, the methods in the interface are abstract, because each class might implement each method differently. If a "Dog" class and a "Cat" class both implemented "Animal", and animal had abstract method "makeNoise()", the class "Dog" might implement the method differently (prints "woof" to the screen) than the "Cat" class (prints "meow" to the screen). I hope this has helped!!! If you have any questions, please ask!!!
26th Oct 2017, 11:55 AM
Quantallax
+ 10
yeah..it is a big help...thank you so much @Quantallax...I like your explaination...Food and apple stuff. 😛😛..very clear 👍👍👍👍👍👍
26th Oct 2017, 12:12 PM
Andrew Ting Mai Zau
Andrew Ting Mai Zau - avatar
+ 7
simplified: you know that a bird and an airplane fly but, you don't know how they do that
29th Oct 2017, 7:23 PM
kernelpanic_r
kernelpanic_r - avatar