confusing related to member hiding

19 Views Asked by At

if static method of child class is hidden by static method of parent class having the same signature, then why is my output as follows:

public class Main 
{
    public static void main(String args[])
    {
        Obcount.num_obj();
        Doing.num_obj();
        
    }
}


class Obcount{
    static int count;
    Obcount(){
        count++;
    }
    static void num_obj() {
        
        System.out.println("i am parent class");
    }
    
}

class Doing extends Obcount{
     double i;
     double j;
     Doing(double i,double j){
         this.i = i;
         this.j = j; 
     }
     void prod() {
         System.out.print(i*j);
     }
     static void num_obj() {
         System.out.print("i am child class");
     }
    
     void div() {
            System.out.println(i/j);
        }
}

The output is:

i am parent class i am child class

shdnt the second line of output be " i am parent class" as well? pls clarify

0

There are 0 best solutions below