Girl in IT-wolrd

Everything has been downloaded. Quit download loop.

Tag Archives: core

Java Interview Q&A. Java Core.[1-25/240]

This post opens series of posts about Java Core Interview Questions and Answers.

1) what are static blocks and static initializers in Java ?
Static blocks or static initializes are used to initialize static fields in java. we declare static blocks when we want to initialize static fields in our class. Static blocks gets executed exactly once when the class is loaded . Static blocks are executed even before the constructors are executed.

2) How to call one constructor from the other constructor ?
With in the same class if we want to call one constructor from other we use this() method. Based on the number of parameters we pass appropriate this() method is called.
Restrictions for using this method :
1) this must be the first statement in the constructor
2)we cannot use two this() methods in the constructor

Read more of this post

Advertisements