Question: What are getters and setters?

  1. Getters and setters ensure that if a data member is declared private, then it can be accessed only within the same function, not by an outside class
  2. Getters and setters are utility functions within PHP that allow loading from, and saving to, a database
  3. Getters and setters encapsulate the fields of a class by making them acccessible only through its private methods, and keep the values themselves public
  4. Getters and setters are methods used to declare or obtain the values of variables, usually private ones

Answer: The correct answer of the above question is Option D:Getters and setters are methods used to declare or obtain the values of variables, usually private ones