File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Abstract  Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Abstract  Class" Watch "Abstract  Class" New topic
Author

Abstract Class

Hemant Gupt
Greenhorn

Joined: May 12, 2008
Posts: 26
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

Joined: May 12, 2008
Posts: 26
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

Joined: Aug 31, 2004
Posts: 11343

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 ]

    "We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
    sscce.org
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Abstract Class
     
    Similar Threads
    abstract method overriding
    Dan's Mock Test on Nested classes
    questions about Dan mock up exam
    combination of access & non-access modifiers for a class
    abstract