• 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

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
Aniket Patil
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks toukhir mujawar,

Thanks for your reply..
 
Aniket Patil
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ?
 
reply
    Bookmark Topic Watch Topic
  • New Topic