• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Abstract Class

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
    reply
      Bookmark Topic Watch Topic
    • New Topic