Category: 05. Polymorphism

  • Java instanceof

    The java instanceof operator is used to test whether the object is an instance of the specified type (class or subclass or interface). The instanceof in java is also known as type comparison operator because it compares the instance with type. It returns either true or false. If we apply the instanceof operator with any variable that has null…

  • Static Binding and Dynamic Binding

    Connecting a method call to the method body is known as binding. There are two types of binding Understanding Type Let’s understand the type of instance. 1) variables have a type Each variable has a type, it may be primitive and non-primitive. Here data variable is a type of int. 2) References have a type…

  • Polymorphism in Java

    Polymorphism in Java is a concept by which we can perform a single action in different ways. Polymorphism is derived from 2 Greek words: poly and morphs. The word “poly” means many and “morphs” means forms. So polymorphism means many forms. There are two types of polymorphism in Java: compile-time polymorphism and runtime polymorphism. We can perform…

  • Final Keyword In Java

    The final keyword in java is used to restrict the user. The java final keyword can be used in many context. Final can be: The final keyword can be applied with the variables, a final variable that have no value it is called blank final variable or uninitialized final variable. It can be initialized in the constructor…

  • Super Keyword in Java

    The super keyword in Java is a reference variable which is used to refer immediate parent class object. Whenever you create the instance of subclass, an instance of parent class is created implicitly which is referred by super reference variable. Usage of Java super Keyword 1) super is used to refer immediate parent class instance variable. We…

  • Covariant Return Type

    The covariant return type specifies that the return type may vary in the same direction as the subclass. Before Java5, it was not possible to override any method by changing the return type. But now, since Java5, it is possible to override method by changing the return type if subclass overrides any method whose return…

  • Method Overriding in Java

    If subclass (child class) has the same method as declared in the parent class, it is known as method overriding in Java. In other words, If a subclass provides the specific implementation of the method that has been declared by one of its parent class, it is known as method overriding. Usage of Java Method Overriding…

  • Method Overloading in Java

    If a class has multiple methods having same name but different in parameters, it is known as Method Overloading. If we have to perform only one operation, having same name of the methods increases the readability of the program. Suppose you have to perform addition of the given numbers but there can be any number of arguments, if you…