Trusted by students across multiple disciplines!
Access modifier - Answer: specifies what region of the code will have access to a field,
method, or class
Where are access modifiers located? - Answer: In front of the datatype for a variable,
start of the method, start of the class.
Public access modifier - Answer: The Java access modifier public means that all code
can access the class, field, constructor or method, regardless of where the accessing
code is located.
Protected access modifier - Answer: Access is limited to the containing class or types
derived from the containing class. Meaning access in the class, package, and
subclasses only
Default access modifier - Answer: means package private. Meaning that fields,
methods, and class are only accessible within the package in which it is located.
Private access modifier - Answer: The term (private) is used in Java designating limited
access to data or methods to only objects of that particular class. Meaning only
accessible within the class.
What are the different parts of a method? - Answer: Access Modifier, Return type,
Name of the method, Parenthesis which contains parameters if any, and open and
closing curly braces, and between the curly braces the body of the method or
functionality we want the method to perform.
Can you nest methods in methods in Java? - Answer: No, the compiler will get angry.
1
APPHIA - Crafted with Care and Precision for Academic Excellence.