in Education by

How will you call a default method of an interface in a class in Java8?

1 Answer

0 votes
by
How will you call a default method of an interface in a class in Java8?

Using super keyword along with interface name.

interface Vehicle {

   default void print() {

      System.out.println("I am a vehicle!");

   }

}

class Car implements Vehicle {

   public void print() {

      Vehicle.super.print();                  

   }

}

Related questions

0 votes
    How will you call a static method of an interface in a class in Java8?...
asked Nov 8, 2020 in Education by Editorial Staff
0 votes
    What is the default function call method in C?...
asked Nov 9, 2020 in Technology by JackTerrance
0 votes
    How will you create a Base64 encoder that encodes using the URL and Filename safe type base64 encoding scheme in Java8?...
asked Nov 8, 2020 in Education by Editorial Staff
0 votes
    How will you create a Base64 decoder that decodes using the URL and Filename safe type base64 encoding scheme in Java8?...
asked Nov 8, 2020 in Education by Editorial Staff
0 votes
    How will you create a Base64 encoder that encodes using the MIME type base64 encoding scheme in Java8?...
asked Nov 8, 2020 in Education by Editorial Staff
0 votes
    How will you create a Base64 decoder that decodes using the MIME type base64 encoding scheme in Java8?...
asked Nov 8, 2020 in Education by Editorial Staff
0 votes
    How will you create a Base64 encoder in Java8?...
asked Nov 8, 2020 in Education by Editorial Staff
0 votes
    How will you create a Base64 decoder in Java8?...
asked Nov 8, 2020 in Education by Editorial Staff
0 votes
    How will you get the sum of all numbers present in a list using Java 8 in Java8?...
asked Nov 8, 2020 in Education by Editorial Staff
0 votes
    How will you get the instant of zoned date time using time in of milliseconds using java8 in Java8?...
asked Nov 8, 2020 in Education by Editorial Staff
0 votes
    How will you get the instant of local date time using time in of milliseconds using java8 in Java8?...
asked Nov 8, 2020 in Education by Editorial Staff
0 votes
    How will you get the instant of current date in terms of milliseconds using java8 in Java8?...
asked Nov 8, 2020 in Education by Editorial Staff
0 votes
    How will you get second saturday of next month using java8 in Java8?...
asked Nov 8, 2020 in Education by Editorial Staff
0 votes
    How will you get next tuesday using java8 in Java8?...
asked Nov 8, 2020 in Education by Editorial Staff
0 votes
    How will you add 10 years to current date using local datetime api of java8 in Java8?...
asked Nov 8, 2020 in Education by Editorial Staff
...