What is non static block in java
Answer Posted / syed
class demoStaticnonstatic
{
int i;
demoStaticnonstatic()//constructor
{
System.out.println("Under Constructor");
}//end
static//static block
{
System.out.println("Under static block");
}//end
//non-static block
{
System.out.println("Under non-static
block");
}//end
public static void main(String[] args)
{
System.out.println("under main method!");
demoStaticnonstatic d=new
demoStaticnonstatic();
}
}
STATIC BLOCK: is used in real time senarios, it provide
information regording the project(name.company,version etc)
before actually project executed.
NON-STATIC BLOCK:is used for - if we have many constructor
in a application and those constructor have same statements
instead of repeate those statement in each constructor,we
place that statement in non-static block.
| Is This Answer Correct ? | 25 Yes | 2 No |
Post New Answer View All Answers
Explain the use of shift operator in java. Can you give some examples?
What do you understand by final value?
Why are pointers not secure?
os is developed in c no java is more secured then c na why dont the os developed is developed using java
What is math floor in java?
Can bool be null?
Which collection does not allow duplicates in java?
Which is bigger float or double?
What is this keyword used for?
If we don’t want some of the fields not to serialize how to do that?
What is the unit of plancks constant?
What is matcher in java?
What is a bufferedreader?
What is the purpose of main function in java?
What is the different between get and post?