• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Interface - AbstractClass Collision

 
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Why am i getting error in above code? Please if somebody can explain underlying reason for it?
 
Bartender
Posts: 11445
18
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because abstract and private are like oil and water. They do not mix
 
Sheriff
Posts: 21783
103
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh is right. Abstract means the method is meant to be overridden, but private methods cannot be overridden (only shadowed).
 
Azrael Noor
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You for reply

but what about following case as there is default in class and public in interfaces and it is working fine why so? as methods are abstract both sides?

 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a method is overridable at all, you can always override it with fewer restrictions. So overriding package or protected methods with public is fine.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error that you are getting looks really strange.

java.lang.ClassFormatError: Method display in class demoprograms/azrael has illegal modifiers: 0x402


It indicates that the class file is invalid. Somehow the compiler that you are using has accepted illegal code (a method that is both abstract and private) without giving an error message, and produced an invalid class file. That's a bug in the compiler.

Which compiler are you using? Is this the standard javac from the JDK (if so, what version)?
 
Azrael Noor
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for providing information

I am Using JDK version 6, JAVAC

what other compilers are available which compile Java Code?
 
Marshal
Posts: 65365
248
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you get that compiler from?
 
Azrael Noor
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From Oracle Website
 
Campbell Ritchie
Marshal
Posts: 65365
248
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am very surprised it would allow those two modifiers together. Maybe the class was compiled with a different compiler, or (even) it has been altered after compilation. Or there was an error in transmission or recording of the .class file.
 
Azrael Noor
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BUG IN JAVA BUG IN JAVA

but i need to continue the program


 
Campbell Ritchie
Marshal
Posts: 65365
248
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Azrael Noor wrote:BUG IN JAVA BUG IN JAVA

I suggest you try compiling that class again, with the same version of the compiler, before you try to report a bug
 
You showed up just in time for the waffles! And this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!