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 major advantage of external iteration over internal iteration?
What are functions in java?
Should a main method be compulsorily declared in all java classes?
Can we use this () and super () in a method?
What are the different types of inheritance in java?
Can we synchronize static methods in java?
What is empty list in java?
What is the largest number a double can hold?
what is collatration?
Can we increase array size dynamically in java?
Can we start a thread twice in java?
What are the limitations of procedural programming approach?
What is collections framework?
What are the advantages of defining packages in java?
Hi Anyone know the model / questions of the Federal bank sample questions for the post of Specialist Officers - Programmers. Please post if anyone have..