• 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

Method Instance Override

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

What is the correct terminology for a Method that is Overridden at Instance level.

Example, the given class DotCom.java has a Method checkYourself that returns the String "miss".



I am familiar with the idea of a subclass overriding the Method to produce different behaviour.

But what if I create an instance and override the method like this,



This method is overridden at instance rather than class level.

How would this be described in TextBooks?

Thanks in advance

Jon
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you are making things more complicated by creating an anonymous class. You won't find that in a basic textbook. You are creating an instance of a class without a name, which inherits from dot com, and has an overridden method.
 
Ranch Hand
Posts: 514
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did not meet so far any difference between overridding method in top class or in inner class or in anonymous class.
Overridden means method that is present in superclass and subclass.
 
Jon Greenwood
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anonymous Class - That's the phrase I'm after.

Thank you very much.

 
Campbell Ritchie
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Volodymyr Levytskyi wrote:I did not meet so far any difference between overridding method in top class or in inner class or in anonymous class.

There is a major difference: you cannot override the method in an anonymous class because you cannot write extends Foo.

Overridden means method that is present in superclass and subclass.

That only applies to instance methods. You cannot override a static method.
reply
    Bookmark Topic Watch Topic
  • New Topic