Classes Quiz

Below are the answers to the Classes Quiz, along with a brief discussion.

1. True. Classes are reference types, while their counterpart, structs, are value types.

2. Classes define what a particular type of thing can store, while an object is a specific instance that contains its own set of data.

3. Instance variables, methods, and constructors can all be members of a class. Later chapters discuss delegates, events, operator overloads, and indexers, which can also be class members.

4. True. In VB.NET, instead of a static keyword, they use the term "shared" which is pretty accurate. Anything that is marked as static belongs to the type definition (class) as a whole, instead of any particular instance.

5. Constructor. A constructor is essentially just another method, but instead of returning a value, they instruct the computer on how to actually build instances of the type.

6. private indicates that the member can only be accessed from within the type that it is a member of.

7. public indicates that anyone who has access to the type has access to the member as well.

8. internal indicates that it is similar to public, except that you don't want it to be accessed by other assemblies. If something is public then it can be loaded by another assembly (DLL or EXE) and used from there. internal prevents this from happening, though this can be circumvented by reflection.