0 votes
in JAVA by

Is the following program written correctly? If yes then what will be the output of the program?

abstract class Calculate  

{  

    abstract int multiply(int a, int b);  

}  

   

public class Main  

{  

    public static void main(String[] args)  

    {  

        int result = new Calculate()  

        {      

            @Override  

            int multiply(int a, int b)  

            {  

                return a*b;  

            }  

        }.multiply(12,32);  

        System.out.println("result = "+result);  

    }  

}  

1 Answer

0 votes
by
Yes, the program is written correctly. The Main class provides the definition of abstract method multiply declared in abstract class Calculation. The output of the program will be:

Result :384

Related questions

0 votes
asked Mar 2, 2021 in LISP by SakshiSharma
0 votes
asked May 3, 2021 in JAVA by Robindeniel
...