Skip to main content

Compile-time Binding and Run-time Binding (Static & Dynamic Binding)


Consider the following program:

class Parent
{
   public void demo(double d)
    {
        System.out.println("Parent "+d);
    }

   public void test(double d)
    {
        System.out.println("Parent Test "+d);
    }
}

class Child extends Parent
{
   public void demo(int d)
    {
        System.out.println("Child "+d);
    }
   public void test(double d)
    {
        System.out.println("Overriding test in Child "+d);
    }
}

class CompileTimeBinding
{
   public static void main(String...rk)
    {
        Parent p = new Child();
        p.demo(5);   //Compile time Binding
        p.test(5);   //Run-time Binding


       
      }
}

Comments

  1. Thanks a lot for sharing this with us, was a really interesting post. and I want to share information about the
    Visit: Best Java Course

    ReplyDelete
  2. Very nic article keep growing. for more article's like this and other study material, programmig language free training, latest tips and tricks, sports and politics news and much more visit to https://searchofia.blogspot.in/

    ReplyDelete
  3. Usually I never comment on blogs but your article is so convincing that I never stop myself to say something about it. This paragraph gives clear idea for the new viewers of blogging, Thanks you. You’re doing a great job Man, Keep it up.
    Java Training in Noida

    ReplyDelete
  4. Hello Everybody,
    My name is Mrs Sharon Sim. I live in Singapore and i am a happy woman today? and i told my self that any lender that rescue my family from our poor situation, i will refer any person that is looking for loan to him, he gave me happiness to me and my family, i was in need of a loan of S$250,000.00 to start my life all over as i am a single mother with 3 kids I met this honest and GOD fearing man loan lender that help me with a loan of S$250,000.00 SG. Dollar, he is a GOD fearing man, if you are in need of loan and you will pay back the loan please contact him tell him that is Mrs Sharon, that refer you to him. contact Dr Purva Pius,via email:(urgentloan22@gmail.com) Thank you.

    ReplyDelete
  5. This excellent website truly has all of the info I wanted concerning this subject and didn’t know who to ask.
    Best Core Java Training in Bangalore

    ReplyDelete
  6. Very nice post you have shared here, I found many informative article in your blog.
    Thanks a lot for your posting
    Spring MicroServices Online Training

    ReplyDelete
  7. Thank you.You have shared nice and unique information about Java Course

    ReplyDelete
  8. Good Post! Thank you so much for sharing the post, it was so good to read and useful to improve
    Java Training in Electronic City

    ReplyDelete

Post a Comment

Popular posts from this blog

ETE Practice Set-1

                                                                 Mock Test-1 -----------------------------------------------------------------------------------------------------------------------------   1 (a) Write a program that reads 10 integers between 1 and 100 and counts the occurrences of each. Assume the input ends with 0.                                                         ...

Practice Set: Unit-4

                                                                                                                Practice Set: Unit 4 1. What are the uses of super keyword in Java? Explain with a suitable example. 2. What are the various uses of final keyword in java? An abstract method can not be declared final. Why? 3. Differentiate between Abstract class and Interface. What do you mean by Functional interface and Lambda Expression?  ...

OLA-UBER Problem

Create two interfaces OLA and UBER both having a method public static Cab getCab() which returns the Cab object where Cab is a nested class inside OLA and UBER. Cab must have attributes cab_number and driver_name. A user rides 5 times using cabs of OLA and UBER randomly which are stored in an array. Now implement a method which should display the name of the driver and the company name i.e. OLA/UBER when the valid cab_number is entered by the user. Display "Invalid CAB details" when the cab_number entered by the user is incorrect.