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 be only accessed by the class itself. This declaration is
A
Private
B
Public
C
Protected
D
Reserved
Explanation: 

Detailed explanation-1: -Answer: only instance methods in the same class .

Detailed explanation-2: –Only classes available in the same package. Methods, Variables and Constructors that are declared private can only be accessed within the declared class itself.

Detailed explanation-3: -Private Access Modifier-Private Methods, variables, and constructors that are declared private can only be accessed within the declared class itself. Private access modifier is the most restrictive access level.

Detailed explanation-4: -We have used the getter and setter method to access the private variables. Here, the setter methods setAge() and setName() initializes the private variables. the getter methods getAge() and getName() returns the value of private variables.

There is 1 question to complete.