Lecture 10: Interfaces
Interfaces:
class A extends B extends C
{
----
}
i.e. multiple inheritance is not permitted in java.
-A large number of real life applications require the use of multiple inheritances.
-For this problem, java provides an alternate approach known as interfaces to support the concept of multiple inheritance.
-Here, Amphibeous_vehicle is having now two copies of method move() one from class vehicle_on_water and one from class vehicle_on_road.
Now, when we are creating object of class Amphibeous_vehicle and calling its move() method, then there will be problem of which method will be called.
-This is the problem with multiple inheritances, so java does not support multiple inheritances.
*Solution to above multiple inheritance:
-Java achieves multiple inheritances by means of special construct known as Interface.
-Let us consider the example of class Animal.
-class animal have some methods say description () & move().
When sub class of this class is created say as Bird, cow & fish all have their own different description as well as way of moving.
-Cow have four legs, big body, gives birth to child where as Birds have small body, two legs & lays egg.
-Now consider the class vehicle which require description () & move (). As these methods are in class animal, so vehicle class may inherit Animal class.
-In doing so the vehicle class may be getting all attributes of class Animal which are totally irrelevant to vehicle, so we will declare interface which have this two methods description () & move(), which will then be inherited by both the class &let every class implement this methods &define all the methods according to their way.
-Using interface we can fully abstract a class from its implementation that is you can specify what a class must do, but not how it does it.
-Interface may have number of methods but all the methods must be abstract (without body).
* Defining an interface:
- An interface is defined much like a class as,
access interface name
{
return_type method_name1(parameter list);
return_type method_name2(parameter list);
final type var_name1=value;
.
}
The java compiler adds public and abstract keywords before the interface method and public, static and final keywords before data members.
-Variable are implicitly final and static, meaning they cannot be changed by implementing class. They must also be initializing with a constant value.
All methods and variables are implicitly public, if the interface itself declare as public.
Please like comment share and subscribe.
Prof. Amol M. Jagtap
For more contact : 7972761065
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Lecture 10: Interfaces», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.