Topic 1.2: Java Basics - Define the structure of a Java class Flashcards
What are the 4
access modifiers
in java
these include:
* public
* protected
* private
* default / package private
The structure for this is as follows:
Access_modifier class class_name { Fields Constructors Getter methods Setter methods Other methods }
what is the
srtucture of a basic class
these members are Accessible within the same package or subclasses
what is the accessibility of
members with the protected access modifier
within a class file what is the order that must be maintained
The order for this is:
- Package declaration (if present): Specifies the package to which the class belongs
- Import statements (if present): Used to import other classes or packages referenced by the class
- Class declaration.
Not maintaining this order will result in a compile-time error.
these members are Accessible only within the same class
what is the accessibility of
members with the private access modifier
what is the accessibility of
members with the public access modifier
these members are Accessible from anywhere
what is the accessibility of
members with the default (package private) access modifier
these members are
Accessible within the same package
these include:
* public
* protected
* private
* default / package private
What are the 4
access modifiers
in java
what is the accessibility of
members with the protected access modifier
these members are Accessible within the same package or subclasses
The order for this is:
- Package declaration (if present): Specifies the package to which the class belongs
- Import statements (if present): Used to import other classes or packages referenced by the class
- Class declaration.
Not maintaining this order will result in a compile-time error.
within a class file what is the order that must be maintained
these members are
Accessible within the same package
what is the accessibility of
members with the default (package private) access modifier
what is the accessibility of
members with the private access modifier
these members are Accessible only within the same class
these members are Accessible from anywhere
what is the accessibility of
members with the public access modifier
what is the
srtucture of a basic class
The structure for this is as follows:
Access_modifier class class_name { Fields Constructors Getter methods Setter methods Other methods }