aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes abstract Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "abstract" Watch "abstract" New topic
Author

abstract

Sireesha Mullapudi
Ranch Hand

Joined: Jun 26, 2006
Posts: 74
Hi,

why the following progaram is not giving error at line3


private and abstract can't be applied together.Then why it is not giving error?


Thanks
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9622
    
    2

Hi Above,

The class B that you declare inside class A is like any other member of A which means it is applicable to private, protected, default, and public access.

Regards,
Jothi Shankar Kumar. S


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Aniket Patil
Ranch Hand

Joined: May 02, 2006
Posts: 218
The answer is right in your post. A private abstract class can always be extended as you have done through class C. Hence, the combination of private and abstract is allowed for nested classes and interfaces.
[ October 17, 2006: Message edited by: Aniket Patil ]

SCJP 5.0 | SCWCD 1.4 <br /> <br />If you don't know where you are going, any road will take you there!
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Originally posted by Aniket Patil:
combination of private and abstract is allowed for member classes and interfaces.


its mean that outside(not a member) abstract class cannot be extends in private class.

correct me if I am wrong..
[ October 17, 2006: Message edited by: Saif Uddin ]

Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Aniket Patil
Ranch Hand

Joined: May 02, 2006
Posts: 218

its mean that outside(not a member) abstract class

You mean a top-level class abstract class


cannot be extends in private class.

Cannot understand that. Perhaps a rephrase would be appropriate.
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Originally posted by Aniket Patil:
combination of private and abstract is allowed for member classes and interfaces.




outside class D

[ October 17, 2006: Message edited by: Saif Uddin ]
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9622
    
    2

Hi Saif,

You cannot declare a class private. It can have only public or default access. Only memeber classes can be declared private.

private class D extends A // I am asking about this..
{

}

is actually not correct.

Regards,
Jothi Shankar Kumar. S
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Originally posted by Jothi Shankar Kumar Sankararaj:

You cannot declare a class private. It can have only public or default access. Only memeber classes can be declared private.



Oh! really sorry for that mistake but my senario is different is not actually this what i paste in my last post.

Sorry again..



this Code give me an error can any one explain me.. why compiler come up with error ?

thanks
[ October 17, 2006: Message edited by: Saif Uddin ]
toukhir mujawar
Ranch Hand

Joined: Oct 11, 2006
Posts: 70
actually you can not declare the implementation of an abstract class as private unless it is a member class...

thus
private class D extends class A {
}
is wrong...
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Thanks toukhir mujawar,

Thanks for your reply..
Aniket Patil
Ranch Hand

Joined: May 02, 2006
Posts: 218
Line 2 will not compile, in addition you need to provide implementation for method m1() of class A in class AB. With these changes, compilation is fine.
[ October 18, 2006: Message edited by: Aniket Patil ]
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Originally posted by Aniket Patil:
Line 2 will not compile, in addition you need to provide implementation for method m1() of class A in class AB. With these changes, compilation is fine.


after implementation of mehtod ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: abstract