answersLogoWhite

0


Best Answer

Yes you can overload the static method.

But it should be avoided because memory to static methods are allocated at the time of class load.....so memory will be wasted if we don't use that methods.

Whereas non-static method memory allocation depends on Object

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

yes you very can very much to be likely. here is example of overloading static method in Java:

public static int size(Object o)

public static int size(Collection c)

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can you overload static methods in Java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering
Related questions

How do you overload static methods in java?

Just create two methods with the same name, but with different types or numbers of parameters.


What does the 'this' reference do in Java?

Represents the current object (not usable in static methods).


How do you access the static variable and static methods of a class?

In java we access static variables and static methods without creating objects. i.e.,we can access directly by using classname we can also access static variables and static methods by using objects which are created by using class where the static variables and static methods are available


Can you inherit static method in java?

Yes. While it is sometimes considered bad style to override static methods, you can treat them like any non-static methods when it comes to inheritance topics.


Can a method be static and synchronized?

Yes. In Java methods can be static and synchronized. Static methods access other static members in the class. Static in case of inheritance are treated as non - static. Synchronized methods are those which have dedicated thread attached to it and no other can access until currrent thread leaves the control from it.


When you overload a Java method you write multiple methods?

Yes. The definition of function overloading is multiple methods with the same name, but different numbers of arguments and return types. static int getArea(int height, int width) { return height * width; } static double getArea(double height, double width) { return height * width; }


Which one executed first static block or static methods in java?

Static Blocks are always executed first. A static block is executed when your class is charged but a static method is executed only when is called, therefor first the class is charged and then is executed a method.


What is Static method in programming?

A static method in java is also named a class method, because it does not need an instance (of his class) to be invoked. Static methods can't use instance variables (non static variables) or use the keywords 'this'. These methods receive all the information they need to complete his task from his parameters


Difference between procedure and function in C or C plus plus or Java language?

In C there are functions only, In Java methodsonly (static methods as well), in C++ both.


Static membors partispating Overwriting in java?

Static membors partispating in Overwriting in java?


Is it possible to define a java static method inside a main method?

Because, the main method is the starting point of the java program and if we need an object of that class even before the main can be invoked, it is not possible. Hence it is declared static so that the JVM Can acess the main method without having to instantiate that particular class


What is the difference between overloading and overriding methods in object?

Here are some of the most common differences between both of them. If you are working in Java for more than 1 year, you might be familiar with all of them but any way its good revision: 1) First and major difference between Overloading and Overriding is that former occur during compile time while later occur during runtime. 2) Second difference between Overloading and Overriding is that, you can overload method in same class but you can only override method in sub class. 3) Third difference is that you can overload static method in Java but you can not override static method in Java. In fact when you declare same method in Sub Class it's known as method hiding because it hide super class method instead of overriding it. 4) Overloaded methods are bonded using static binding and Type of reference variable is used, while Overridden method are bonded using dynamic bonding based upon actual Object. 5) Rules of Overloading and Overriding is different in Java. In order to overload a method you need to change its method signature but that is not required for overriding any method in Java.