‹ Back to the paper
What is an interface? How is it different from a class?
Answer
Answer
AIAn interface in Java is a reference type that contains only abstract method declarations (no method bodies) and constants (public static final fields). It specifies what a class must do, and any class that implements it (using the keyword implements) must define all its methods.
Difference from a class: a class contains data members and complete method definitions and can be instantiated with new, whereas an interface has no instance variables, no method bodies and cannot be instantiated. A class can inherit from only one class (extends) but can implement many interfaces, so interfaces give a form of multiple inheritance.
From ISC 2017 Computer Science Paper 1, question 2(a).