File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Abstract Class

 
Hemant Gupt
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
code:
--------------------------------------------------------------------------------

public class AS{ private class AB extends A{} } abstract class A { // 1 private abstract void m1(); // 2 private abstract class B {} // 3 private class C extends B {} // 4 }

--------------------------------------------------------------------------------



this Code give me an error can any one explain me.. why compiler come up with error ?
 
Hemant Gupt
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apologies for d above format
code:
--------------------------------------------------------------------------------

public class AS{
private class AB extends A{}
}

abstract class A { // 1
private abstract void m1(); // 2
private abstract class B {} // 3
private class C extends B {} // 4 }

--------------------------------------------------------------------------------



this Code give me an error can any one explain me.. why compiler come up with error ?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Hemant Gupt:
...this Code give me an error can any one explain me.. why compiler come up with error ?

I think the error messages are pretty clear:
  • illegal combination of modifiers: abstract and private [in] private abstract void m1();
  • AS.AB is not abstract and does not override abstract method m1() in A

  • If a method is abstract, that means the implementation will be provided is a subclass. But if a method is private, then it cannot be overridden. Therefore, abstract and private cannot be used together on a method.

    If a class extends an abstract class, then it must either provide implementation for any abstract methods it inherits or be declared abstract itself.
    [ June 16, 2008: Message edited by: marc weber ]
     
    Don't get me started about those stupid light bulbs.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic