• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about overload

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hollo,everyone:
If must transfer overload , what should noted?
if there type the same , how about casting ?
if casting the same ?
 
Ranch Hand
Posts: 522
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Yu-Jie Jang:
Hollo,everyone:
If must transfer overload , what should noted?
if there type the same , how about casting ?
if casting the same ?


Hi Yu and welcome to the ranch, i am not trying to be rude here, but can you please clarify what you are saying, cause honestly... i have no idea what you're talking about.
 
Yu-Jie Jang
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry i missing one question
when I overload :
B extends A
A a=new A();
A b=new B();
if A have private vaiable x and default y,
B have private y and default x,
methed call ?
variable call ?
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Yu:
After reading what you mentioned, I think your question is not about overload, it may be override.When one class has methods which have same name and different types of arguments, like:
public int method(){};
private double method (int x){};

The question you mentioned can be separate into 2 parts variable and method();
Variale:
Without considering the static or instance variables,when you call the variable, it depends on the type.It means if the code is A a = new B(); when you call a.x or a.y, it will show the class A's variable value.
Method():
1.It is different in static and instance method().First, The static method() can't override instance method() and instance method() can't override static method.
2.If the subclass and it's superclass have same static method();when you call the method();it depends on type like variable(This situation may be called Hide).
3.If the subclass and it's superclass have same instance method();when you call the method();it depends on type like object.It means if the code is A a = new B(); when you call a.x(), it will execute the class B's method().Thos situation may be called override.
Conclude( s = static i = instance)

Please tolerat my poor English, and hope it can help you !
[ December 28, 2003: Message edited by: Chao Chihwai ]
reply
    Bookmark Topic Watch Topic
  • New Topic