ADVANCED TOPICS IN COMPILER DESIGN
CODE GENERATION FOR OBJECT ORIENTED LANGUAGES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
Public
|
|
Private
|
|
Protected
|
|
Reserved
|
Detailed explanation-1: -Calling a public method from another class “public” is one of them that is accessible inside as well as outside of a class/package. Example: invoke a public method from some other class. In this program, we will create two classes “FirstClass” and “SecondClass” as shown in the below-given code blocks: FirstClass.
Detailed explanation-2: -Static public Objects In order to access fields that are located in a different class, you need to use dot notation. In this case, to access the obj field, you would need to use an instance of Class1 . Class1 c1 = new Class1(); //Code to instantiate all the variables, etc.
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: -The public keyword is an access specifier. Access specifiers define how the members (attributes and methods) of a class can be accessed. In the example above, the members are public-which means that they can be accessed and modified from outside the code.