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 do you mean by exception handling in Java?
Print Vertical traversal of a Binary Tree.
What does file separator do in java?
Why we use set in java?
What is the purpose of javac exe?
How do you make an arraylist empty in java?
What is the purpose of a parameter?
How are observer and observable used in java programming?
Write a program to print count of empty strings in java 8?
What is data structure in java?
What is difference overloading and overriding?
What is console based application in java?
What is function and method in java?
What is the purpose of stub and skeleton?
How will you invoke any external process in java?