Home » JAVA Programming » Interfaces » Question
  1. What is the output of this program?
    interface calculation
    {
    void calculate(int Num);
    }
    class display implements calculation
    {
    int p;
    public void calculate(int Num)
    {
    p = Num * Num;
    }
    }

    public class interfaces_Example
    {
    public static void main(String args[])
    {
    display object = new display();
    object.p = 0;
    object.calculate(4);
    System.out.print(object.p);
    }
    }
    1. 0
    2. 4
    3. 16
    4. Compilation Error
    5. Runtime Error
Correct Option: C

16



Your comments will be displayed only after manual approval.