Python Programming - Encapsulation - Discussion
Discussion Forum : Encapsulation - General Questions (Q.No. 50)
50.
Consider the following Python code:
class Employee:
def __init__(self, name, salary):
self._name = name
self._salary = salary
def get_salary(self):
return self._salary
What is the purpose of the get_salary()
method in this code?
Answer: Option
Explanation:
The
get_salary()
method is designed to retrieve the salary of an employee, demonstrating encapsulation by providing controlled access.
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers