LearnFrenzy
Sign in Take a free test

Static and Final Keywords · Find the Error · Question 10

Error: an abstract static method Answer, explanation & discussion

  • Find the error
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 10 Back to Exercise

The program below does not compile. Which statement correctly describes the problem?

Main.java
abstract class Shape {
    abstract static double unitArea();
}

public class Main {
    public static void main(String[] args) {
        System.out.println("shapes");
    }
}
  • A Shape must be an interface
  • B A method cannot be both abstract and static: static methods are not overridden, so an abstract one could never be implemented Correct
  • C double cannot be returned
  • D Abstract classes cannot have methods
Correct Answer: Option B

javac: "illegal combination of modifiers: abstract and static".

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links