PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

Java · Theory

Interface in java

← All stacks

Theory

45/270

Interface in java

An interface is a contract: if you implement me, you must provide these behaviours. class Circle implements Drawable. A class can implement many interfaces — multiple capabilities.

Good names sound like abilities: Runnable, Comparable, Drawable. Modern Java can add default and static methods, but the core idea is still the contract: what you can do, not a family of shared fields.

If you mainly need shared fields and shared code, consider an abstract class. Interview line: interface = can-do contract; a class may implement many.

Let's take this on the board with one tiny Main class — no extra files. Interface in java — output: Draw circle. Drawable d = new Circle() is allowed — interface type, real Circle object. Start from main, go line by line, and stop at each print. That output is the proof for Interface.

Diagram
interface Drawable
    draw()
         │ implements
         ▼
      Circle.draw()
Exam tip

Multiple interfaces vs single superclass.

Example

interface Drawable {
  void draw();
}
class Circle implements Drawable {
  public void draw() { System.out.println("Draw circle"); }
}
public class Main {
  public static void main(String[] args) {
    Drawable d = new Circle();
    d.draw();
  }
}

Interface in java — output: Draw circle. Drawable d = new Circle() is allowed — interface type, real Circle object.

Short notes

  • DefInterface = contract. Implement me → provide these behaviours.
  • Ruleimplements keyword. A class can implement many interfaces.
  • RememberNames are capabilities — Runnable, Comparable, Drawable.
  • DiffNeed shared fields/code? Think abstract class. Need can-do? Interface.

Questions

1

What is an interface?

2

How many interfaces can a class implement?

3

What keyword is used?

Previous← Abstract class in JavaNextDifference between Abstract Class and Interface in Java →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.