🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: OOP Interview Questions: all 10 questions

Quiz: OOP Interview Questions · Question 7 of 10

What does this print? (code)

What does this print?

class Parent {
    static String kind() { return "parent"; }
}

class Child extends Parent {
    static String kind() { return "child"; }
}

public class Main {
    public static void main(String[] args) {
        Parent p = new Child();
        System.out.println(p.kind() + " " + Child.kind());
    }
}
  1. A.child child
  2. B.parent parent
  3. C.parent child
  4. D.Compile error
Answer & explanation

Correct answer: parent child

Static methods are hidden, not overridden: p's declared type Parent decides the first call.

Can you get the rest right without peeking?

Take the timed Quiz: OOP Interview Questions quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →