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 properties class?
Do I need java on my computer?
what is heap memory?
What is java util hashmap?
Differences between external iteration and internal iteration?
Which java collection does not allow null?
What is an example of procedure?
Is map sorted in java?
What is an argument in java?
Why do we need hashset in java?
What is a generic type?
Explain working of call by reference function invoking.
Which one will take more memory: an int or integer?
What is prime number in java?
What is collection class in java? List down its methods and interfaces.