1/14
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Object
a member of a Java class, with its own identity, behaviour, and state
Enum:
A datatype when an objects Structure or state can only have one of a small set of values
Packages
-A namespace that organizes a set of related classes and interfaces
-“different folders on your computer”
Access modifiers of a class
Public, default private
default Class Access modifier:
accessible only within the same package
private Class Access modifier:
modifiers only apply to nested classes
Access modifiers for class members:
Public default private protected
public class member access modifier
accessible from everywhere in the program
default class member access modifier:
accessible only within the same package
private class member access modifier
accessible only within the class in which they are declared
protected class member access modifier:
accessible within the same package or subclasses in different packages
encapsulation
-Wrapping the variables and code acting on the methods together as a single unit
-variables of a class will be hidden from other classes and can be accessed only though the methods of their current class
To achieve encapsulation in Java:
-declare the variables of a class as private
-provide public setter and getter methods to modify and view the variables values
This keyword
-refers to the current object in a method
-eliminates the confusion between class attributes and parameters with the same name constructors
Class
-when defined in java, it is usually a new data type
-Used to make multiple objects, defined by its properties