KnowledgeBoat Logo
|

Computer Applications

How many types of methods are generally there in a class ?

Encapsulation & Inheritance in Java

2 Likes

Answer

The member methods of a class can be categorized into following three categories :

  1. Accessor Methods — These are public member methods of the class that allow us to access the data members (instance variables) of object. They cannot change the value of data members. They are used to read values of private data members of a class which are directly not accessible in non-member methods.
  2. Mutator Methods — These member methods allow us to change the data members of an object. Any member method that changes the values of an instance variable of a class is a mutator method.
  3. Manager Methods — These are member methods with specific methods (e.g., constructors) that deal with initializing class instances.

Answered By

1 Like


Related Questions