Can we overload the methods by making them static in Java?

No, We cannot overload the methods by just applying the static keyword to them(number of parameters and types are the same). Consider the following example.

  1. public class Animal
  2. {
  3.     void consume(int a)
  4.     {
  5.         System.out.println(a+” consumed!!”);
  6.     }
  7.     static void consume(int a)
  8.     {
  9.         System.out.println(“consumed static “+a);
  10.     }
  11.     public static void main (String args[])
  12.     {
  13.         Animal a = new Animal();
  14.         a.consume(10);
  15.         Animal.consume(20);
  16.     }
  17. }

Output

Animal.java:7: error: method consume(int) is already defined in class Animal
    static void consume(int a)
                ^
Animal.java:15: error: non-static method consume(int) cannot be referenced from a static context
        Animal.consume(20);
              ^
2 errors