Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

quick interface question  RSS feed

 
Jennifer Schwartz
Ranch Hand
Posts: 46
Firefox Browser Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two short questions on an interface extending another interface:

My first (original) interface might have the following method sig:



while the sub-interface (don't know correct term) contains:



Is this last interface overriding the signature of the original? Because they are still ints, we are just changing the number of arguments...I have looked at many tutorials and still can't seem to get this.

And last question...If this interface is being extended, does the new interface have to be implemented once more by the next non-abstract class?


 
Jan Cumps
Bartender
Posts: 2632
17
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For your first question:
http://download.oracle.com/javase/tutorial/java/IandI/override.html
The overriding method has the same name, number and type of parameters, and return type as the method it overrides.
 
Jennifer Schwartz
Ranch Hand
Posts: 46
Firefox Browser Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, then it's actually overloaded because the # of parameters have actually changed.

So in regards to the actual implementation of the signature:

In overriding we are creating a new version of the method by changing it's implementation.

In overloading, does this mean we are pretty much creating a separate method?


Just trying to understand what each means to the functionality of the method...thanks!
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jennifer Schwartz wrote:... In overriding we are creating a new version of the method by changing it's implementation.

In overloading, does this mean we are pretty much creating a separate method? ...

Yes.
 
Jennifer Schwartz
Ranch Hand
Posts: 46
Firefox Browser Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahh, a silver lining...I CAN be taught! It's these small breakthroughs that keep one motivated!
 
David Byron
Rancher
Posts: 175
Clojure Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


From the perspective of Why?:

With overriding, we feel the power of the Dark Side polymorphism by making subclasses behave differently from their supers.

With overloading, we provide convenience for callers of the method by accommodating a variety of sets of arguments (that may or may not drive different behavior).
 
Igor Mechnikov
Ranch Hand
Posts: 100
Chrome Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Byron wrote:



With overriding, we feel the power of the Dark Side



May the Schwartz be with you!
 
Jennifer Schwartz
Ranch Hand
Posts: 46
Firefox Browser Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ilya Mechnikov wrote:
David Byron wrote:



With overriding, we feel the power of the Dark Side



May the Schwartz be with you!


GOOD one Ilya!!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!