Ask 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 ();

public int foo2 ()

{

return 5;

}

}

+4
Answers (1)
  1. 22 June, 14:07
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers