LogiQuest
Back to Interfaces and Abstract Classes
1

What is the output of the following program?

interface Shape { double area(); default String name() { return "shape"; } }
class Sq implements Shape { public double area() { return 4; } }
class Main { public static void main(String[] args) { Shape s = new Sq(); System.out.println(s.name() + " " + s.area()); } }
Medium

Discussion (0)

  • No discussion yet. Ask a doubt or share a shortcut.

Log in to join the discussion.