By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,779 Members | 1,101 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,779 IT Pros & Developers. It's quick & easy.

overloading in java

P: 1
what is object overloading in java?
Jan 8 '07 #1
Share this Question
Share on Google+
3 Replies


10K+
P: 13,264
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
Jan 8 '07 #2

P: 4
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.overloading Means Mehods Available In The Same Class. Overriding Means Relation Between Super Class Method And Subclass Method Giribabu
Jan 10 '07 #3

10K+
P: 13,264
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.overloading 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

Expand|Select|Wrap|Line Numbers
  1.  
  2. class A {
  3.  public Number a() {
  4.   return 1;
  5.  }
  6. }
  7. class B extends A {
  8.  public Integer a() {
  9.   return 1;
  10.  }
  11. }
  12.  
Compiles fine in 1.5 but not on 1.4 compilers
Jan 10 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.