Default method in interface in java – part 1

This default method comes to scene when developers need to update existing interface without updating that interface implement classes updating.

Default methods must have to have an implementation.  And developer can update default method as they want but implemented classes can decide either update with newly added default method or not.

Go through below example.

import utils.CarUtils;

public interface CarCategorization {
public void displayManualCarList();
    public void displayAutoCarList();
    public void displayTipTronicCarList();

    default public void displayUpcomingCarList(){
        System.out.println("Hybrid Card List Started");
CarUtils carUtils = new CarUtils();
System.out.println("Hybrid Card List End");

public class CarList implements CarCategorization {
public static void main(String[] args) {
CarList c = new CarList();

public void displayManualCarList() {
        System.out.println("Dx Wagon, Lancer");

public void displayAutoCarList() {
        System.out.println("AE110, Nissan sunny");

public void displayTipTronicCarList() {
        System.out.println("Celerio, ALTO");

package utils;

public class CarUtils {
public CarUtils() {
public void displayGraceHybridCarList(){

public void displayToyotaHybridCarList(){


One thought on “Default method in interface in java – part 1

Add yours

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at

Up ↑

%d bloggers like this: