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

Practice MCQs

  1. What will be the Output of the following code? class X{                  static int x = 1;                        static class Y {                              static int y = x++;                                static class Z                                                                       {                                                                                         static int z = ++y;                                                                        }                                               }                }   class MainClass{     public static void main(String[] rk)    {                             System.out.print(X.x);                                             System.out.print(X.Y.y);                             System.out.print(X.Y.Z.z);         } } A. 113 B. 123 C. 111 D. None of These Ans: A 2.  Which of the following statement is TRUE about t he following code? public class Outer  {    private i

Practice Set

1. Write a program to create a class Voter which contains attributes name, date_of_birth and voter_id and voter has a Voter_Card. Provide appropriate constructor to initialize all the attributes of the Voter but voter id must be assigned automatically only when the age of the voter is greater than or equal to 18 years. VoterCard is a nested class with attributes voter_id and Voter_name. Make sure that voter card is created only when user is a valid voter and if it is already created then must not be assigned the new voter id. 2. Write a program to define two interfaces UGC and AICTE both having a default method int getAdmission() to take the admission and an abstract method String payFee(). getAdmission() in UGC must ask the percentage in qualifying exam and if the percentage >= 60 then generate the registration number and return. getAdmission() is AICTE must ask the user to join the counseling after 5 days and display the date of counseling and return the counseling token numb

Mock Test - 1

1. Which of the following is a byte stream class? A. ObjectInputStream B. Writer C. PrintWriter D. Scanner Ans: A 2. Which exception is thrown by read() method in InputStream class? A. IOException B. InterruptedException C. FileNotFoundException D. None of These Ans: A 3. Which of the following class is subclass of FilterInputStream? A. InputStream B. ObjectOutputStream C. FileInputStream D. BufferedInputStream  Ans: D 4. Which of these class contains the print() and println() methods? A. System B. out C. PrintStream D. BUfferedOutputStream Ans: C 5. Which of these is a method to clear all the data present in output buffer without terminating the stream? A. clear() B. fflush() C. flush() D. close() Ans: C 6. Which of these classes defined in java.io and used for file-handling are abstract? (i) InputStream        (ii) PrintStream    (iii) Reader        (iv) FileInputStream A. Only i     B. i and ii    C. Only iii    D. i and iii Ans: D 7. What is the output of this program? class MyE