Interview Q&A / Java

INTERVIEW Q&A · 72 QUESTIONS

Java interview questions

Collections, the JVM, strings, exceptions and threads, the backbone of most campus placement rounds.

  1. What is the difference between method overloading and method overriding in Java?

    Overloading is several methods with the same name but different parameters in one class, resolved at compile time. Overriding is a subclass replacing a parent method with the same signature, resolved at runtime.

    BeginnerQuick answer1 min read
  2. What does this Java code print when a parent reference holds a child object?

    Methods are looked up on the real object at runtime, so the child version runs. Fields are looked up on the reference type at compile time, so the parent field is read. Fields are never polymorphic.

    IntermediateQuick answer1 min read