Ask Question
21 May, 22:16

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;

}

}

+5
Answers (1)
  1. 22 May, 02:06
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers