Search Interview Questions
| More than 3000 questions in repository.|
There are more than 900 unanswered questions.
Click here and help us by providing the answer.
Have a video suggestion.
Click Correct / Improve and please let us know.
|Java - Interview Questions and Answers|
Can do meta object operations ( like validating something before creating objects , keep count of number of objects )
Can do operations which have nothing to do with objects but still you want them to be tied to Class.
Commonly used to static variables sometime leads to problems due to access by different objects.
Are not tied to objects so doesn't reflect pure Object Oriented approach.
Needs to be synchronized so as to avoid update conflicts by mutiple objects and threads.
Some limitation in testing as not all frameworks have facility to mock them. Powermock has but Mockito doesnt
|Help us improve. Please let us know the company, where you were asked this question :|
|Like Discuss Correct / Improve  java   static   static variables   static methods|
|How can we run a java program without making any object?|
| Which of the following combination of keywords is illegal in Java ? |
a. static and transient
b. transient and final
c. static and synchronized
d. abstract and final
|Difference between Static and Singleton Class ?|
|Why do we write public static void main ? Can we use some other syntax too for main ?|
|Can we declare static variables as transient ?|
| What is the difference between the following two code lines ?|
1. new OuterClass().new InnerClass();
2. new OuterClass.InnerClass();
|Can we access instance variables within static methods ?|
| Which of the following can be marked static ?|
a. Methods , Variables and Initialization Blocks.
b. Methods , Variables , Initialization Blocks and Outer Classes and nested Classes.
c. Methods , Variables , Initialization Blocks and Outer Classes.
d. Methods , Variables , Initialization Blocks and nested Classes
|Enums cannot be declared ..|