Comment on Tutorial - Abstract classes in Java By Kamini
Comment Added by : srini
Comment Added at : 2012-08-03 14:42:58
Comment on Tutorial : Abstract classes in Java By Kamini
this is useful for you,
Abstract classes cannot be instantiated directly. Declaring a class as abstract means that you do not want it to be instantiated and that the class can only be inherited. You are imposing a rule in your code.
If you extend your Parent/Child relationship example further to include a Person class then it would make good sense for Person to be abstract. Parent is a concrete idea and so is child. Person is an abstract concept in reality as well as in code.
One benefit is that you explicitly define and protect the idea of the abstract class. When you declare a class as an abstract there's no way that you or anyone else using your code uses it incorrectly by instantiating it. This reasoning is similar to why we specify functions and fields as public, private or protected. If you declare a function or member as private you are in effect protecting it from improper access from client code. Privates are meant to be used within the class and that's it. Abstract classes are meant to be inherited and that's that.
Now, do you have to use abstract classes and define functions and fields as private instead of public? No, you don't. But these concepts are provided to help keep code clean and well-organized. The abstract class is implemented in all object-oriented languages to my knowledge. If you look around you will see that C++, C#, VB.NET etc. all use this concept.
- Data Science
- Cloud Computing
- Java Beans
- Mac OS X
- Office 365
- Tech Reviews
Subscribe to Tutorials
2. where i can find Messageressourse.properties......
View Tutorial By: sanjiv at 2013-09-07 06:59:19
5. i'm really hoping this example was wrote before 19
View Tutorial By: Anonymous at 2009-06-07 21:00:18
6. it would be very helpful if you demonstrated how t
View Tutorial By: newcoder at 2011-10-24 17:40:25
7. i have a problem ie., Animal is the super class an
View Tutorial By: renuka at 2012-08-29 15:08:33
8. Thanks a lot.. it made my concepts of memmove,mems
View Tutorial By: Rimmi Jain at 2009-07-23 06:42:01
9. sir, thanks sir. very help to me. its simple and e
View Tutorial By: kannathasan.M at 2012-10-01 07:59:28