java 30 | interface in java | total abstraction in java смотреть онлайн
In this class we are going to talk about interface in java
interface is used to achieve total abstraction
interface is a blueprint of a class
it specifies a set of methods that the class has to implement
If a class implements an interface and does not provide method bodies for all functions specified in the interface, then the class must be declared abstract.
As you already know that abstraction in java is showing the functionality not the working (what it does not how it does)
Abstract class is one way of achieving abstraction
Interface is another way (total abstraction)
Like a class, an interface can have methods and variables, but the methods declared in an interface are by default abstract (only method signature, no body).
Interfaces specify what a class must do and not how
It cannot be instantiated just like the abstract class.
how to declare an interface
An interface is declared by using the interface keyword.
interface interface_name{
// declare constant fields
// declare methods
}
Ex : - interface Printable {
int MIN=5;
void print( );
}
example
interface printable{
void print();
}
class Test implements printable{
public void print()
{ System.out.println(“Printing…..”); }
public static void main(String args[ ]){
Test obj = new Test();
obj.print();
}
}
Output : Printing….
In this example, the Printable interface has only one method, and its implementation is provided in the Test class.
another example
interface Bank{
float rateOfInterest();
}
class SBI implements Bank{
public float rateOfInterest(){return 9.15f;}
}
class PNB implements Bank{
public float rateOfInterest(){return 9.7f;}
}
class TestInterface2{
public static void main(String[] args){
Bank b=new SBI();
System.out.println("ROI: "+b.rateOfInterest());
}}
Output- ROI: 9.1
If a class implements multiple interfaces, or an interface extends multiple interfaces, it is known as multiple inheritance.
summary
Intrface is used to achieve abstraction.
It is used to achieve multiple inheritance.
We can’t create instance(interface can’t be instantiated) of interface but we can make reference of it that refers to the Object of its implementing class.
List of suggested readings
https://www.geeksforgeeks.org/interfaces-in-java/
Java: The Complete Reference Book by Herbert Schildt
https://www.youtube.com/playlist?list=PLA3taA2THXpy0q0TxYd4i5dpk76HpsZ_n
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «java 30 | interface in java | total abstraction in java» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.