Revature Interview Question: What is a setter/ what is a g... | Glassdoor

Interview Question

Software Developer Interview Houston, TX

What is a setter/ what is a getter? What is their purpose?


Interview Answer

4 Answers


Setter and Getters are functions that modify private variables.

Shawn on Jun 14, 2017

Setter is a public function that changes value of private variable. Getter is a public function that retrieves the value of a private variable.

Anonymous on Aug 1, 2018

Setters and getters are public methods to modify private class variables. It’s a very good example of how to ease the fear of students being introduced to ENCAPSULATION. I remember seeing encapsulation and polymorphism and feeling my heart race (not to mention static variables and immutable and mutable objects.

Name on Sep 23, 2018

P.s. The purpose is to avoid giving full access to those variables, sometimes referred to as fields

Name on Sep 23, 2018

Add Answers or Comments

To comment on this, Sign In or Sign Up.