Sunday, June 14, 2020

MethodOveriding

MethodOveriding

Method Name having  sameName,SameParamter,sameSignature,sameDataType

package programs;
// A Simple Java program to demonstrate
// method overriding in java
  
// Base Class
class Parent {
    void show()
    {
        System.out.println("Parent's show()");
    }
}
  
// Inherited class
class Child extends Parent {
    // This method overrides show() of Parent
    @Override
    void show()
    {
        System.out.println("Child's show()");
    }
}
  
// Driver class
class Main {
    public static void main(String[] args)
    {
        // If a Parent type reference refers
        // to a Parent object, then Parent's
        // show is called
        Parent obj1 = new Parent();
        obj1.show();
  
        // If a Parent type reference refers
        // to a Child object Child's show()
        // is called. This is called RUN TIME
        // POLYMORPHISM - Interview question
        Parent obj2 = new Child();
        obj2.show();
    }
}


Overriding is done so that a child class can give its own implementation to a method which is already provided by the parent class. 

1 comment:

  1. Automation Testing Selenium with Java Interview Kit+50 Resumes(1 to 8+yrs )

    Today i will release new module Selenium with java Interview Question and Answers Kit.

    This will include 500+ Interview Question and Answers along with 50+ Resumes(1-8 Yrs Experience level Resumes).

    Access will provide Today At 6 PM interested people please registred your self by using below link:

    https://imjo.in/RWabG4

    Note: We are in teaching field since 8 yrs
    Please go through below proofs how this course look like


    ReplyDelete

Selenium_Grid_With_Docker_Compose(yml file)

 docker-compose.yml version: "3" services:   hub:     image: selenium/hub:3.141.59     ports:       - "4444:4444"   chro...