• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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 ]
     
    Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad:
    Gift giving made easy with the permaculture playing cards
    https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    reply
      Bookmark Topic Watch Topic
    • New Topic