Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes Interface - AbstractClass Collision Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Interface - AbstractClass Collision" Watch "Interface - AbstractClass Collision" New topic
Author

Interface - AbstractClass Collision

Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382



Why am i getting error in above code? Please if somebody can explain underlying reason for it?


Regards
Azrael Noor
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

Because abstract and private are like oil and water. They do not mix


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19679
    
  18

Maneesh is right. Abstract means the method is meant to be overridden, but private methods cannot be overridden (only shadowed).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382
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?

Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4371
    
    8

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.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114
    
  16

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)?

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382
Thank you for providing information

I am Using JDK version 6, JAVAC

what other compilers are available which compile Java Code?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38481
    
  23
Where did you get that compiler from?
Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382
From Oracle Website
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38481
    
  23
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

Joined: Jul 29, 2010
Posts: 382
BUG IN JAVA BUG IN JAVA

but i need to continue the program


Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38481
    
  23
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Interface - AbstractClass Collision