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 treeset in java collection?
How do you change an int to a string?
What is the purpose of using break in each case of switch statement?
What is xslt in java?
Why doesn't the java library use a randomized version of quicksort?
What is a two-pass assembler?
What are wrapper classes in java?
Can we override the static method?
What is jrmp?
What is formatted output in java?
What ide should I use for java?
How big is a gigabyte?
Can you sort a list in java?
What is the biggest integer?
What do you understand by java?