Menu
Question Index
...

Define a class ComplexEquation such that it overrides the method calculate() and returns the result as 4a^3 + 7b^2 + 13.
Note: 4a^3+7b^2+ 13 where a^3 is a power 3 and b^2 is b power 2.

Class Used, Input1, Input2 Output
ComplexEquation, 2, 3 108
ComplexEquation, -3, 1 -88
Equation, -5, 4 38
Equation, 1, -2 2



class OverrideCalculateMethod
{
    public static void main(String s[])
    {
        Equation equation = new ComplexEquation();
        System.out.println("The output with parameters 2 and 3 is " + equation.calculate(2,  3));

    }



}
class Equation
{
    int calculate(int a, int b)
    {
        return a * a + 2 * b + 5;
    }
}

class ComplexEquation extends Equation
{
}

Doubts

Problems

Topic: Abstract Method In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App