0 votes
12 views

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

in Education by (49.4k points)

1 Answer

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

Using name of the interface.

interface Vehicle {

   static void blowHorn() {

      System.out.println("Blowing horn!!!");

   }

}

class Car implements Vehicle {

   public void print() {

      Vehicle.blowHorn();                  

   }

}
by (49.4k points)

Related questions

0 votes
1 answer 10 views
0 votes
1 answer 21 views
0 votes
1 answer 12 views
0 votes
1 answer 12 views
0 votes
1 answer 9 views
0 votes
1 answer 10 views
0 votes
1 answer 16 views
...