Example & Tutorial understanding programming in easy ways.

Can we override the static method?

The answer is ‘Yes’. We can have two ore more static methods with same name, but differences in input parameters.

For example, consider the following Java program.

example:

public class javatest {

public static void fun() {

System.out.println("javatest.fun() called ");

}

public static void fun(int a) {

System.out.println("javatest.fun(int) called ");

}

public static void main(String args[])

{

javatest.fun();

javatest.fun(10);

}

}

output :-javatest.fun() called

javatest.fun(int) called

 

Read More →