what is the difference between statis block and static
variable
Answer Posted / manikandan [ gtec,vellore ]
static variables hold only one value and static block is a
set of code. static variables and static methods are loaded
before a main method.it loads one by one in top down approach.
consider this code:
class test
{
static{
System.out.println(i);//compile error bcas top down approach
}
static int i=1;
public static void main(String[]asd)
{
}
}
| Is This Answer Correct ? | 6 Yes | 1 No |
Post New Answer View All Answers
What is the difference between method overriding and overloading?
What is the full name of java?
how we can use debug in myeclipse 6.0 in order solve the problems that exist in our program when there are 900 to 1000 pages in a web application
What is the difference between reader/writer and inputstream/output stream?
List two java ide’s?
Which sort is best in java?
Can we modify the throws clause of the superclass method while overriding it in the subclass?
'A class is a template for an object' explain this statement.
What is main method?
Can we inherit inner class?
What are static blocks in java ?
Why is the singleton pattern considered to be an anti pattern?
what is the major difference between linkedlist and arraylist in java?
What is the difference between superclass and subclass?
Explain how hashmap works?