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?

Answer

Interview Answer

4 Answers

14

Setter and Getters are functions that modify private variables.

Shawn on Jun 14, 2017
0

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
5

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
0

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.