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
Differences between traditional programming language and object oriented programming language?
What is the use of private static?
Explain java coding standards for interfaces?
Explain hashset and its features?
What is classes in java?
Explain the private field modifier?
What is a nested structure?
How we can generate random numbers in java?
Is null in java?
What is methods in java?
What is difference between wait and notify in java?
What is the significance of listiterator?
Does it matter in what order catch statements for filenotfoundexception and ioexception are written?
What is java util list?
What is OOP Language?