overloading in java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pmanickam
    New Member
    • Jan 2007
    • 1

    #1

    overloading in java

    what is object overloading in java?
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by pmanickam
    what is object overloading in java?
    It is called method overloading and is when you have 2 or more methods in the same class with the same name but taking different number and or types of arguments

    Comment

    • GUNDALA GIRIBABU
      New Member
      • Jan 2007
      • 4

      #3
      In A Class When There Are More Than One Method With The Same Name With Different Parameters And Same Or Different Return Type Then Metods Are Said To Be Overloading.the Differance Between Overloading And Overriding Is Overriding Means Relation Between Super Class And Subclass In Overriding Method Signature Must Be Same Including Return Type.in Overloading Method Signature Should Differ.in Overriding It Blocks Inheritance.ove rloading Means Mehods Available In The Same Class. Overriding Means Relation Between Super Class Method And Subclass Method Giribabu

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by GUNDALA GIRIBABU
        In A Class When There Are More Than One Method With The Same Name With Different Parameters And Same Or Different Return Type Then Metods Are Said To Be Overloading.the Differance Between Overloading And Overriding Is Overriding Means Relation Between Super Class And Subclass In Overriding Method Signature Must Be Same Including Return Type.in Overloading Method Signature Should Differ.in Overriding It Blocks Inheritance.ove rloading Means Mehods Available In The Same Class. Overriding Means Relation Between Super Class Method And Subclass Method Giribabu
        As of 1.5 you can override a method with one that has a return type which is a subclass of the parent class method

        Code:
         
        class A {
         public Number a() {
          return 1;
         }
        }
        class B extends A {
         public Integer a() {
          return 1;
         }
        }
        Compiles fine in 1.5 but not on 1.4 compilers

        Comment

        Working...