In a class definition, keywords called modifiers can precede the class keyword. The modifiers available are: public, abstract, and final. To discover which modifiers have been applied to a given class, you first get a Class object representing that class using the getClass() method. Next, you would call the getModifiers() method on the class object to return a bitmapped int value representing the modifiers. You can then use static methods of the java.lang.reflect.Modifier class to determine which modifiers have been applied. The static methods available are: isPublic(), isAbstract(), and isFinal(). Note If you have a class object that may represent an interface, you might also want to use the isInterface() method. This method will return true if the modifiers passed in include the interface modifier. The Modifier class also contains additional static methods for determining which modifiers have been applied to class methods and variables. These methods include: isPrivate(), isProtected(), isStatic(), isSynchronized(), isVolatile(), isTransient(), isNative(), and isStrict(). |