Static classes versus regular classes
What is a static class? How is it different from an object?
A class in which everything (all fields and methods) is static is equivalent to an object. It has state and behavior. However – such an ‘object’ may not work – since everything about the object needs to be known at compile time. For e.g. – if the type of O.S. was one of the fields, it would need to be determined at runtime.
Why not just make every class static?
The strength of OO programming is in the fact that each instance of a given class can contain different data/behavior than another instance. The only way to maintain state is to instantiate regular (non static) classes.
Leave a Reply