Interfaces Interview Questions

    Question 1JAVA OOPS - Interface Basics

    Which of the following is true about interfaces in Java?

    Question 2JAVA OOPS - Implementing Interface

    What will be printed?

    interface A { void show(); } class B implements A { public void show() { System.out.println("Hello"); } } public class Main { public static void main(String[] args) { A obj = new B(); obj.show(); } }

    Question 3JAVA OOPS - Multiple Interface Implementation

    Which of the following is correct?

    interface A { void showA(); } interface B { void showB(); } class C implements A, B { public void showA() { System.out.println("A"); } public void showB() { System.out.println("B"); } }

    Question 4JAVA OOPS - Default Methods in Interface

    Which is true about default methods in Java interfaces?

    Question 5JAVA OOPS - Interface Reference

    Which statement is correct?

    interface A { void show(); } class B implements A { public void show() { System.out.println("Hi"); } }

    Question 6JAVA OOPS - Interface with Variables

    Which of the following statements is true?

    Question 7JAVA OOPS - Interface and Abstract Class

    Which is true?

    Question 8JAVA OOPS - Static Methods in Interface

    Which is valid in Java 8+?

    interface Demo { static void show() { System.out.println("Hello"); } } public class Main { public static void main(String[] args) { Demo.show(); } }

    Question 9JAVA OOPS - Interface Inheritance

    Which of the following is correct?

    Question 10JAVA OOPS - Purpose of Interface

    What is the main purpose of interfaces in Java?