COMPILER DESIGN

ADVANCED TOPICS IN COMPILER DESIGN

CODE GENERATION FOR OBJECT ORIENTED LANGUAGES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Methods and attributes in an object can be set to restrict access to members of a subclass (programming language specific). This declaration is
A
Protected
B
Private
C
Public
D
Reserved
Explanation: 

Detailed explanation-1: -Encapsulation is a way to restrict the direct access to some components of an object, so users cannot access state values for all of the variables of a particular object. Encapsulation can be used to hide both data members and data functions or methods associated with an instantiated class or object.

Detailed explanation-2: -Private Variables can be only be accessed outside the class if public getter methods are present in the class. Using the private modifier object encapsulates itself from the outside world and restrict the access to it.

Detailed explanation-3: -Access Modifiers: Access specifiers or access modifiers in python programming are used to limit the access of class variables and class methods outside of class while implementing the concepts of inheritance.

Detailed explanation-4: -Python’s convention to make an instance variable protected is to add a prefix (single underscore) to it. This effectively prevents it from being accessed unless it is from within a sub-class.

There is 1 question to complete.