RUVIDEO
Поделитесь видео 🙏

Tutorial 29: Inheritance смотреть онлайн

📁 Обучение 👁️ 16 📅 05.12.2023

Inheritance is a mechanism in which one class acquires the property of another class. For example, a child inherits the traits of his/her parents. With inheritance, we can reuse the fields and methods of the existing class. Hence, inheritance facilitates Reusability and is an important concept of OOPs.
The super keyword in java is a reference variable that is used to refer parent class objects.  The keyword “super” came into the picture with the concept of Inheritance. It can be used for variables, methods & Constructors.
1. Use of super with variables: This scenario occurs when a derived class and base class has same data members. In that case there is a possibility of ambiguity for the JVM.
2. Use of super with methods: This is used when we want to call parent class method. So whenever a parent and child class have same named methods then to resolve ambiguity we use super keyword.
3. Use of super with constructors: super keyword can also be used to access the parent class constructor. One more important thing is that, ‘’super’ can call both parametric as well as non parametric constructors depending upon the situation.
Program :
package Inherit;

public class Main {

public static void main(String[] args) {
animal a1 = new animal("a1",21,5);
Dog d1 = new Dog("scooby",2,15,1);
// d1.eat();
d1.run();
//d1.walk();
}
}

(animal.java)
package Inherit;

public class animal {
private String name;
private int weight;
private int height;

public animal(String name, int weight, int height) {
this.name = name;
this.weight = weight;
this.height = height;
}
public void eat(){
System.out.println("eating animal");
}
public void move(int speed){
System.out.println("Animal speed of movement is "+ speed);

}

public String getName() {
return name;
}

public int getWeight() {
return weight;
}

public int getHeight() {
return height;
}
}


Dog.java
package Inherit;

public class Dog extends animal {
private int eyes;
private int teeth;
private int tail;

public Dog(String name,int eyes,int teeth,int tail ) {
super(name, 20, 13);
this.eyes=eyes;
this.teeth=teeth;
this.tail=tail;
}
private void chew(){
System.out.println("dog chew his food");
}
@Override
public void eat() {
System.out.println("dog is eating");
chew();
super.eat();
}
public void walk(){
System.out.println("Dog is walking");
super.move(5);
}
public void run(){
System.out.println("Dog is running");
move(10);
}

@Override
public void move(int speed) {
System.out.println("Dog.move() called");
super.move(speed);
}
}

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Tutorial 29: Inheritance» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.