What is a static method?
object -oriented method of computer programming, which is declared in the class, but is not dependent on any specific instance of this class, is called a static method. Most programming languages include the keyword static in the Declaration of the Static Method. These methods belong strictly to the class in which they are contained and not to any object installed from this class. They are often referred to as Class methods .
The literal class name is usually used to access the static method instead of referring to the name of the instant object. In Java, it is permissible to use object names to refer to these methods, but is strongly discouraged. If the object name is used, the person who reads the code can confuse one of these methods using the instance method. They are also used when the programmer needs access to the method, but there is no need to install the class in which it is contained. It would be uncommon for a method of usefulness to adjust the infOrmation about an object. The method from the Java.lang.Math class, such as Pow (), would be an example of how this type of method would be used in the service class.
Instance methods can directly approach variable instances, static variables, instance methods and static methods. Static methods cannot directly approach variable instances and instance methods. Due to the nature of instances that have better access to classroom members than static methods, instance methods are the type of methods commonly used in conventional classes.
One main disadvantage of static methods occurs during heritage when polymorphism is used. If the parental static method is not declared the final, the same child's static method can be coded in the child's class as if it were rewritten. This is technically called hiding instead of rewriting because the static method cannot be rewritten.
when using hiding, if availableICI parental static method by means of class name, a superior method will be used. If the overwrite the static method of the child is proceeded using the object name, the overwritten child method will be used. The problem arises when the child's object is upcast as a parent. In this case, calling to upcast Child will use a parental method instead of the child's expected method. With real polymorphism, a subordinate method activated after upcast would be.