We use an interface to abstract the user’s view from the code. It is used to achieve multiple inheritance which is not supported by Java. It is also used to achieve loose coupling.
In real-time it could be used to hide the sensitive data and the functionality from the users like Connection interface in JDBC provides you default functionality to connect your database and it contains abstract methods commit, rollback, etc.
Want to learn Java? Check out the Java certification from Intellipaat.