what is the difference between static block and static
method

Answer Posted / kishore reddy

static{} blocks are executed on its own as soon as the
program starts. i.e before the main method is called where
as static() is called ONLY from another static method ie
main method.

static() has several restrictions:
1. Can ONLY call other static ()
2. MUST ONLY access static data
3. cant refer to super or this

Is This Answer Correct ?    14 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is local variable and instance variable?

604


How many threads does a core java have?

508


What are the different collection views provided by maps?

563


What is the definition of tree ?

585


What do you mean by boolean?

573






Is sizeof a keyword in java programming?

601


How many static init can you have?

676


What is a nested list?

516


What is multi level inheritance in java?

554


What are synchronized methods and synchronized statements in java programming?

568


How can you traverse a linked list in java?

678


Is an integer an object?

513


What does arrays sort do in java?

536


What are reference variables in java?

592


Java is Pass by Value or Pass by Reference?

616