• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

abstract

 
Sireesha Mullapudi
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • 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
 
Joe Harry
Ranch Hand
Posts: 10082
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
Aniket Patil
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • 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 ]
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • 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 Harry
Ranch Hand
Posts: 10082
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • 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: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • 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 ]
 
toukhir mujawar
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • 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: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks toukhir mujawar,

Thanks for your reply..
 
Aniket Patil
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • 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: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • 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 ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic