Back to Browse

🔴polymorphism in java | Run time polymorphism in java | Method Overriding in java | Examples |

68 views
Jun 28, 2020
2:52:14

In this video, I explained what is polymorphism in java with definition and Real World meaning of polymorphism and the main purpose of using polymorphism in java and their benefits and why they segregated into different types. compile-time polymorphism: https://youtu.be/bP_1Q8en2i8 0:00:00 Introduction & Definition & Tyes & Usages 0:02:52 Runtime Polymorphism Definition 0:04:00 Diagramatic Explanation with Examples 0:09:10 Examples with programs 0:10:30 Method Creation and Explanation used terminology 0:14:10 Calculator Class 0:15:00 Why we need to use overriding 0:18:30 Reduce Code in Child Class 0:22:00 Use of IS-A Relationship 0:24:35 How to achieve IS-A Relationship 0:30:00 Why we say Run Time polymorphism/Dynamic Method Dispatch/Late Binding 0:34:33 problems of implementing IS-A Relation 0:40:00 Implementing Method Overriding 0:47:50 Overriden Method vs Overriding Method 0:51:00 How to Check Method properly Override or not 0:52:40 @Override Annotation With Examples 0:55:00 Eclipse shortcut to override methods 0:58:45 Method Signature 1:03:00 Return Type of The Method 1:11:05 How to Change Eclipse Compiler Compliance level 1:12:05 Co-variant Return Type in java 1:17:05 static Methods can't be overridden 1:20:05 Method hiding 1:23:20 final Methods can't be overridden 1:30:20 private Methods can't be overridden 1:34:50 Access Modifiers in java for Methods 1:43:00 final Methods can't be overridden 1:47:00 super keyword in java for calling parent class properties. 2:06:00 Abstract class in java. 2:15:20 interfaces class in java. 2:19:20 Exception Handing in java. 2:38:00 Example with Overriding 2:43:00 Overriding Object Class Methods in the class 2:44:15 Understanding Object Class Implementation in java 2:50:10 Conclusion Polymorphism is one of the OOPs features that allow us to perform a single action in different ways. The process of representing one form in multiple forms is known as Polymorphism. Polymorphism(Greek words) means many forms. Using polymorphism, we can achieve flexibility and readability in our code because we can perform various operations by using methods with the same names according to requirements. Polymorphism can be either static or dynamic depending on how the method is called in a class. Types: compile-time polymorphism and runtime polymorphism. compile-time polymorphism(overloading) : ---------- If a class has multiple methods having the same name but different in parameters, it is known as Method Overloading. Run-time Polymorphism(overriding) : ------------- If the subclass (child class) has the same method as declared in the parent class, it is known as method overriding in Java. RULE : 1. Both the superclass and the subclass must have the same method name, the same return type, and the same parameter list. 2. IS-A Relation 3. We cannot override the method declared as final, static, private In Java, run-time polymorphism can be achieved through method overriding. In this case, the method in the parent class is called "overridden method" and the method in the child class is called "overriding method" why we will use Run Time PolyMorphism Overriding is done so that a "child class can give its own implementation to a method" which is already provided by the parent class. without touching the parent class code. Co-Variant Return Type --------------------- A covariant return means that when one overrides a method, the return type of the overriding method is allowed to be a subtype of the overridden method's return type. final keyword in java ------------------- The final keyword in java is used to restrict the user. The java final keyword can be used in any context. Final can be: variable, method, class Java - Access Modifiers ---------------------------------- You must have seen public, private, and protected keywords while practicing java programs, these are called access modifiers. private - default - protected - public Super Keyword in Java -------------------- The super keyword in Java is a reference variable which is used to refer immediate parent class object. Usage of Java super Keyword super can be used to refer immediate parent class instance variable.super can be used to invoke the immediate parent class method.super() can be used to invoke immediate parent class constructor. exception in Java ------------- An exception is an unexpected event that occurs during the execution of a program that disrupts the normal flow of instructions abstract class in java ------------------- An abstract class is a class that is declared abstract it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed. Abstraction is a process of hiding the implementation details and showing only functionality to the user. interfaces in java ------------------- An interface is a reference type in Java. It is similar to a class. It is a collection of abstract methods. Java Interface also represents the IS-A relationship.

Download

0 formats

No download links available.

🔴polymorphism in java | Run time polymorphism in java | Method Overriding in java | Examples | | NatokHD