Sunday, 15 January 2012
JAVA : What is static in java?
Do you like this Article?
Static means one per class, not one for each object no matter how many instance of a class might exist. This means that you can use them without creating an instance of a class.Static methods are implicitly final, because overriding is done based on the type of the object, and static methods are attached to a class, not an object. A static method in a superclass can be shadowed by another static method in a subclass, as long as the original method was not declared final. However, you can't override a static method with a nonstatic method. In other words, you can't change a static method into an instance method in a subclass.
Subscribe to:
Post Comments
(
Atom
)
Popular Posts
-
public - public means everyone can access it.That means it's in global scope. As, main method is called by JVM [ Java Virtual Machine...
-
throw is used to throw an exception in a program, explicitly . Whereas, throws is included in the method's declaration part, wi...
-
Singleton in one of the most popular yet controversial design pattern, in the world of object oriented programming. It's one of t...
-
Web Container / Servlet Container / Servlet Engine : In J2EE Architecture , a web container (also known as servlet container or ser...
-
Program compiles. But at runtime throws an error “NoSuchMethodError”.
-
Vector : It's synchronized. It's slower than ArrayList. It's generally used in ...
-
doGet(): protected void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, java.io.IOException – is a met...
-
In Java Programming Language , we must declare a variable name and type, before using it. The data type of a variable defines the th...
5 Responses to “ JAVA : What is static in java? ”
9 May 2012 at 13:12
great
18 August 2013 at 12:27
When any member of a class is declared as static then it can be accessed without creating any object of the class.
If a variable is declared as static then even if several objects of the class are created but no copy of the variable is made;all the instances share the same static variable.
If a method is declared as static then that method can access only static data,it can invoke only static methods and it can't use "this" and "super" keyword.
So normally a class member is accessed with the help of an object of a class.But by using static it is possible to access them without creating an object.
25 May 2017 at 16:05
this is very useful for every one who want to learn about static keyword with easy steps and in detail also.
thank you
28 October 2018 at 22:19
nice article thank you.
For java interview programs visit: Java programming
13 January 2020 at 18:07
Thanks for sharing such a useful information. Keep sharing.
Advanced Java training
Post a Comment