Static methods can't be abstract in Java

0 votes

Why doesn't Java allow an abstract method to be defined as static?

For example:

abstract class demo {
    abstract void test( ); // <-- this is ok
    abstract static void test1(); //<-- this isn't why?
Oct 12, 2018 in Java by misc.edu04
• 1,380 points

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Well, Java doesn't allow this because of a basic contradiction.

  • "abstract" means to "Implements no functionality"
  • "static" means that "There is functionality even if you don't have an object instance"

Because of this Java compiler might get confused as to which concept to follow and thus this practice is prohibited in Java.

answered Oct 12, 2018 by v.liyyah
• 1,290 points

Related Questions In Java

0 votes
2 answers

When to use Static Methods in Java?

A static method has two main purposes: For ...READ MORE

answered Aug 9, 2018 in Java by samarth295
• 2,190 points
0 votes
1 answer

Static Map initialization in Java

I would suggest you to use the ...READ MORE

answered May 4, 2018 in Java by Akrati
• 3,150 points
0 votes
1 answer

How can two strings be concatenated in java?

You can concatenate Strings using the + operator: System.out.println("Your number ...READ MORE

answered Jun 6, 2018 in Java by Daisy
• 8,020 points
0 votes
2 answers

How an object array can be converted to string array in java?

System.arraycopy is the most efficient way, but ...READ MORE

answered Aug 8, 2018 in Java by Sushmita
• 6,820 points
0 votes
1 answer

Can Static methods be inherited in java?

A subclass inherits all of the public ...READ MORE

answered Apr 30, 2018 in Java by Daisy
• 8,020 points
0 votes
1 answer

Why the main() method in Java is always static?

As you might know, static here is ...READ MORE

answered May 8, 2018 in Java by geek.erkami
• 2,320 points
0 votes
1 answer

Overriding private or static method in Java

You cannot override a private or static ...READ MORE

answered Jul 30, 2018 in Java by code.reaper12
• 3,450 points
0 votes
1 answer

Can't access static fields in inner classes in Java

Well, the major idea behind this concept ...READ MORE

answered Oct 8, 2018 in Java by anto.trigg4
• 3,420 points
0 votes
1 answer

NoClassDefFoundError in Java

Can’t tell you the exact reason as ...READ MORE

answered May 25, 2018 in Java by v.liyyah
• 1,290 points
0 votes
1 answer

Java Static nested class

Hi, to understand their usage, you must ...READ MORE

answered Jun 7, 2018 in Java by v.liyyah
• 1,290 points

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.