U cannot over-ride the static method.If u do so the compiler wont give u ny error but the behaviour would certainly not the same.
Example
class T
{
static void mth()
{
System.out.println("hiii static");
}
}
class Test extends T
{
static void mth()
{
System.out.println("overridding method");
}
public static void main(String []args)
{
Test.mth();
T.mth();
mth();
T obj=new Test();
obj.mth(); // here u should get d output as "overidding method " bt we get "hii static" as our output
}
}
Example
class T
{
static void mth()
{
System.out.println("hiii static");
}
}
class Test extends T
{
static void mth()
{
System.out.println("overridding method");
}
public static void main(String []args)
{
Test.mth();
T.mth();
mth();
T obj=new Test();
obj.mth(); // here u should get d output as "overidding method " bt we get "hii static" as our output
}
}