Encapsulation is one of the fundamental concepts in object-oriented programming…