I have created a class Check as a parent class and define one method as a static and also one more class Check1 that extends Check class now I created a object of class Check1 and call the Check class method with this object and its work properly. How can it would be possible ? because static method of class work only with the name of class .
Check class:
public class Check
{
static void main(int a[])
{
for(int i=0; i<a.length; i++)
{
System.out.print(a[i] + "\t");
} System.out.println();
}
}
Check1 class:
public class Check1 extends Check
{
public static void main(String a[])
{
Check1 ob=new Check1();
int a1[]={1,2,3,4};
ob.main(a1); // working
main(a1); // working
Check.main(a1); // working
Check1.main(a1); // working
System.out.println("Main");
}
}
give me a solution or am I doing wrong in my program?