Java: Interfaces

Photo by Killian Cartignies on Unsplash

What is a reference type?

Reference data types in Java are those which contain references to the address of dynamically created objects. class types, arrays types, interface types.

Abstract methods in interfaces

Figure 1.1: Comparable Interface
Figure 1.2: Implementing the Comparable Interface

Implementing interfaces

  1. You have to declare that your class intends to implement an interface via the implements followed by the interface name. Example:

Constants in interfaces

Using interface as a type

Figure 2.1: Using an interface as a data type
Figure 2.2: Interface as parameter type and return type

Why use interfaces?

  • Multiple inheritance
  • Organizational benefits
  • Loose coupling potential

Common interview questions on Interfaces

--

--

--

Computer Science Student, Programming Enthusiast

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

HOT PRODUK!!!

Dependency Injection + ServiceLocator Pattern + Unit Testing with Self Created Mocks in Swift

🌟Our unique ecosystem makes it possible to maintain the miner, and function properly!

Blazor WASM with REST API — Step by Step

Pandas Tutorial Part IV — Add /Remove and Sort Columns in DataFrame

The Cherry Airdrop Ends

Histograms and frequently table in Python, an approximation to the selection of the number of bins

Banarasee customer care number 9339244745Banarasee customer care number 9339244745Banarasee…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Anton Suprun

Anton Suprun

Computer Science Student, Programming Enthusiast

More from Medium

Object Oriented Programming with Java

Exceptions in Java

Regular Expressions in Java

Java: Java Source Code Structure