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

Polymorphism in Java | Java Programming Training | Learn Core Java and become Web Developer | Uplat

In this Java session by Uplatz, you will learn about the concept of Polymorphism in Java. Learn Object Oriented Programming (OOP) in java. https://training.uplatz.com/online-it-course.php?id=java-programming-basics-110

To enrol into the complete Java Programming course, simply go to the above link or contact us at:
[email protected]
https://training.uplatz.com

Polymorphism is a fundamental concept in object-oriented programming (OOP) and is a key feature in Java. It allows objects of different classes to be treated as objects of a common superclass during runtime. Polymorphism enables code to be written in a way that is more generic and flexible, promoting code reusability and easier maintenance.

There are two main types of polymorphism in Java:

Compile-time Polymorphism (Method Overloading):
Compile-time polymorphism occurs when the method to be executed is determined during the compilation phase based on the method signature (i.e., method name and parameter types). This is achieved through method overloading.

class MathOperations {
public int add(int a, int b) {
return a + b;
}

public double add(double a, double b) {
return a + b;
}
}

In this example, we have two add methods in the MathOperations class. The compiler decides which method to call based on the number and types of arguments passed to the method during the method invocation. For example:

MathOperations math = new MathOperations();
int sum1 = math.add(5, 10); // Calls the int add(int a, int b) method
double sum2 = math.add(2.5, 3.7); // Calls the double add(double a, double b) method

Run-time Polymorphism (Method Overriding):
Run-time polymorphism occurs when the method to be executed is determined during runtime based on the actual type of the object. This is achieved through method overriding.

class Animal {
public void makeSound() {
System.out.println("Some generic animal sound");
}
}

class Dog extends Animal {
@Override
public void makeSound() {
System.out.println("Woof! Woof!");
}
}

In this example, the Animal class has a makeSound() method, and the Dog class overrides it with a specific implementation for dogs. When we call the makeSound() method on an object of the Dog class, it will execute the overridden version of the method:

Animal animal = new Dog(); // Polymorphic assignment
animal.makeSound(); // Output: Woof! Woof!

Even though the reference animal is of type Animal, it is pointing to an object of the Dog class due to polymorphic assignment. During runtime, the JVM determines the actual type of the object (Dog), and thus, the overridden makeSound() method in the Dog class is called.

Polymorphism allows you to write more flexible and reusable code by treating objects of different classes as instances of a common superclass, enabling dynamic method dispatch based on the actual type of the object at runtime.

---------------------------------------------------------------------------------------------

Uplatz is a global leader in Consulting, Training, Resourcing, Marketing, AI & ML, Cloud, Data, and Analytics.

Uplatz is well known for providing instructor-led training and video-based courses on SAP, Oracle, Salesforce, ServiceNow, Cloud Computing, AWS, Azure, GCP, Big Data, Data Science, Machine Learning, Programming Languages, Python, R, Java, SQL, SAS, Data Engineering, Data Analytics, Google, Microsoft, IBM technologies, Web Development, Software Testing, RPA, Finance, Digital Marketing, and more.

Browse all video courses here:
https://training.uplatz.com/online-it-courses.php

Contact us:
+44 7459302492
[email protected]
https://training.uplatz.com

----------------------------------------------------------------------------------------------------------
#javaprogramming #java #oop

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Polymorphism in Java | Java Programming Training | Learn Core Java and become Web Developer | Uplat», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

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

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

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