Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
2.88/5 (5 votes)
See more:
Hi All,

Let me know why we create static and abstract class.
we know that we can't instantiate static class and is very fast
so why we not create every class as static class..
why we create objects of public class.

when we need static class when abstract class and when public class.....
Posted
Comments
Adarsh chauhan 2-Aug-13 5:44am    
+5 for the question as I too get confuse about when to use static class, when abstract class and when public class.
Hoping for some nice nice answers/links from experts..
Sergey Alexandrovich Kryukov 12-Aug-13 0:12am    
If you are get confused about such things, how come you became the author of 74 answers? Sorry for such a question, but you really should be careful with answers, to avoid possible harm to naive inquirers...
—SA
Adarsh chauhan 12-Aug-13 1:42am    
There is a diff. between getting confused and not knowing at all, and also that no one is perfect in this world. :)
And about your question "how come you became the author of 74 answers?" I would say that I don't post an answer if I don't really know about it.. so you don't need to bother about "possible harm to naive inquirers".
Sergey Alexandrovich Kryukov 12-Aug-13 11:36am    
That's good. Thank you.
I was worrying because the deep knowledge of the issues in current question is very basic in programming. I hope you know what you are writing about...
—SA

Different types have specific uses, and it's rarely about speed. You can look at some of these links[^], and others, for more information.
 
Share this answer
 
Static class is used when you are aware of that the value that you are going to use in entire application will remain same means that at one place you will set the value and from other place you will get that value, at that point of time it's better to use static class.For example Utility classes.

Why we need abstract classes? this link will explain you clearly
http://stackoverflow.com/questions/9652506/why-we-need-abstract-class-when-we-can-inherit-normal-class[^]

Hope this helps
 
Share this answer
 
There are a lot of reason why that static and abstract class created but to make it short. To make your program run faster. Imagine if you are using a procedural type of programming. It is hard for the developer/programmer to debug their program especially if you are working for a large system. That's why our doctors' and engineers' in professions enhance the type of programming and create an Object Oriented Programming in order for all the developer and programmer make their life easier and easy to debug. so part of this OOP develop by our smart developer and programmer are Abstract and static.So this is very important if you want to develop a program. :)
 
Share this answer
 
v3
Static Class[^]

Main advantage with this class type is that you dont have to instantiate it.

Abstract Class[^]

The abstract Identifier in the class declaration indicates that the class can only be used as a base class to others.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900