polymorphism - Java Override a private function Dont showing polymorphic behaviour -


public class shape {  final private void print()  {     system.out.println("in class shape"); }    public static void main(string[] args)   {      shape shape=new rectangle();     shape.print();     //calling shape class function      //giving output in class shape     } 

}

 public class rectangle extends shape  {     public void print()      {     system.out.println("in class rectangle");     //super.print();      }   } 

ques: why private function don't show polymorphic behaviour ? , still overriding final method? calling base class funtion why?

a private function not visible nor callable children; hence these 2 different functions. there nothing overwrite perspective of child class, because not aware parent has print() function.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -