adspace
What is static variable and static method?
Answer Posted / nagina
static variable:
It is a variable which belongs to the class and not to
object(instance).Static variables are initialized only
once , at the start of the execution . These variables will
be initialized first, before the initialization of any
instance variables. A single copy to be shared by all
instances of the class. A static variable can be accessed
directly by the class name and doesn’t need any object
Syntax : <class-name>.<variable-name>
static method:
It is a method which belongs to the class and not to
the object(instance). A static method can access only
static data. It can not access non-static data (instance
variables). A static method can call only other static
methods and can not call a non-static method from it.
A static method can be accessed directly by the class name
and doesn’t need any object
Syntax : <class-name>.<method-name>
A static method cannot refer to "this" or "super" keywords
in anyway
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is a classloader in java?
Write a program to find the whether a number is an Armstrong number or not?
How to create a base64 decoder in java8?
Write a program to print count of empty strings in java 8?
Explain public static void main(string args[]) in java.
What are the differences between heap and stack memory in java?
What is java string pool?
What is a constructor overloading in java?
explain different ways of using thread? : Java thread
Differentiate between static and non-static methods in java.
What is the difference between break and continue statements?
Write a java program to find the route that connects between Red and Green Cells. General Rules for traversal 1. You can traverse from one cell to another vertically, horizontally or diagonally. 2. You cannot traverse through Black cells. 3. There should be only one Red and Green cell and at least one of each should be present. Otherwise the array is invalid. 4. You cannot revisit a cell that you have already traversed. 5. The maze need not be in the same as given in the above example
What is the difference between equals() and == in java?
How to sort array in descending order in java?
What is parsing in java?