Java Developers
Group for Java developers and programmers. Ask questions and get answers related to Java programming
254 Members
Join this group to post and comment.
AdhikariHarika Reshma
AdhikariHarika Reshma
Computer Science
24 Jan 2019

Can we Overload or Override static methods in java?

Overloading:Overloading is related to compile time (or static) polymorphism. This feature allows  different methods to have same name,especially different number of input parameters and type of parameters.

Overriding:Overriding is related to runtime polymorphism. A subclass (or derived class)provides a specific implementation of a method in superclass(or base class) at runtime.

Can we Overload static method:Yes, we can Overload static method in java.We can have two or more static methods with same name but with differences in input parameters.

Can we Override static method:We can declare methods with same signature in subclass ,but it is not considered  overriding as  there wont be any runtime polymorphism. Hence the answer is 'NO'.Static methods cannot be overridden because overriding only occurs in the context of dynamic (i.e.runtime).Static methods(by their name) are looked up statically(at compile time).