Interview Q&A / Java
Java interview questions
Collections, the JVM, strings, exceptions and threads, the backbone of most campus placement rounds.
Prefer rapid revision? Practise Java short interview answers →
- What does the static keyword mean in Java?
static means a member belongs to the class itself, not to any one object. A static variable has one shared copy, a static method can be called without creating an object, a static block runs once when the class is loaded, and a static nested class does not need an outer object.
IntermediateIn-depth3 min read - Why can a static method not use non-static variables or this in Java?
A static method belongs to the class and can run without any object, so there is no this and no instance to read fields from. To use an instance member it must be given an object explicitly.
BeginnerQuick answer1 min read - Can static, private and final methods be overridden in Java?
No. Final methods are forbidden from overriding, private methods are invisible to subclasses, and static methods belong to the class, so a same-named subclass method only hides the parent one instead of overriding it.
IntermediateQuick answer1 min read