Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Static method().....

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
static methods are not overriden right, instead they are hidden.
What does hidden mean?
Static methods cannot be overriden to be non-static. Am i right?
can anyone help me on this!
Thanks.
 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Overridden methods can help for polymorphic behaviour of an object, but hidden can not.
Simply put, the decision to call overriding method or overridden method is taken at run-time (dynamic binding). On the other hand hidden methods are statically bound.
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope it helps, this is how i understand it. See the code below.
class Base
{
static void show() { System.out.println("Base show"); }
}
class child extends Base
{
static void show() { System.out.println("Child show");}
public static void main(String [] args)
{
Base b = new child();
b.show(); // invokes the base method instead of child method
}
In non-static methods(overriding), the child would be called.In overriding, u can invoke the overridden method using super() only. Here (in hiding), u could invoke the overridden method. This is what i read - might give u some insight.
 
Desperado
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just like with class fields (AKA instance variables), which static method to execute is decided by the class of the reference variable and not the object's. Not so for instance methods though...
 
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic