method hiding in java

Solutions on MaxInterview for method hiding in java by the best coders in the world

showing results for - "method hiding in java"
Romina
12 Sep 2019
1class Demo{
2   public static void demoMethod() {
3      System.out.println("method of super class");
4   }
5}
6public class Sample extends Demo {
7   public static void demoMethod() {
8      System.out.println("method of sub class");
9   }
10   public static void main(String args[] ) {
11      Sample.demoMethod();
12     Demo sm= new Sample();
13     sm.demoMethod();
14   }
15}