Ask Question
16 November, 20:01

What is the error and why is there an error in the code below?

public class XYZ

{

public static final int A = 9;

public abstract void foo1 ();

public int foo2 ()

{

return 5;

}

}

+4
Answers (1)
  1. 16 November, 23:35
    0
    The error in the given question is that the class xyz must be abstract i. e

    abstract class xyz.

    Explanation:

    In the given code the class xyz contain abstact method so class xyz must be abstract because abstract class contain abstract method. Abstract class contain final variable and abstract method by default all the method in abstract class is abstract and variable are final.

    Syntax:

    abstract class classname

    {

    //final variable

    / / abstract method

    / / method

    }

    so coorect code is

    abstract class XYZ

    { public static final int A = 9;

    public abstract void foo1 ();

    public int foo2 ()

    {

    return 5;

    }

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “What is the error and why is there an error in the code below? public class XYZ { public static final int A = 9; public abstract void foo1 ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers