A static member is a member you can have access to without instantiating the class into an object. For example, you can read and write static properties and call static methods without ever creating the class. Static members are also called class members (class methods, class properties, etc.) since they belong to the class and not to a specific object. A static class is a class that contains only static members. In the UML, these classes are described as utility classes.
Languages Focus: Static Member
Languages that support static members usually at least support static member fields (the data). Some languages also support static methods, properties, etc. in which case the class member is held in memory at one location and shared with all objects. Finally, some languages support static classes which usually means the compiler will make sure a static class contains only static members.
VB.Net Shared Members
VB.Net supports both static members and static classes (use the keyword Shared). You can add a static method, field, property, or event to an existing class.
You can designate a class as static and the compiler will ensure all methods in that class are static. You can add a constructor to a static class to initialize values.
The CLR automatically loads static classes with the program or namespace.
Syntax Example:
Public Shared Function MySharedFunction() As Integer MySharedFunction = 12345 End Function
The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.