Topic 1.2: Java Basics - Define the structure of a Java class Flashcards

1
Q

What are the 4
access modifiers
in java

A

these include:
* public
* protected
* private
* default / package private

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The structure for this is as follows:

Access_modifier class class_name
{
    Fields
    Constructors
    Getter methods
    Setter methods
    Other methods
}
A

what is the
srtucture of a basic class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

these members are Accessible within the same package or subclasses

A

what is the accessibility of
members with the protected access modifier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

within a class file what is the order that must be maintained

A

The order for this is:

  1. Package declaration (if present): Specifies the package to which the class belongs
  2. Import statements (if present): Used to import other classes or packages referenced by the class
  3. Class declaration.

Not maintaining this order will result in a compile-time error.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

these members are Accessible only within the same class

A

what is the accessibility of
members with the private access modifier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is the accessibility of
members with the public access modifier

A

these members are Accessible from anywhere

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is the accessibility of
members with the default (package private) access modifier

A

these members are
Accessible within the same package

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

these include:
* public
* protected
* private
* default / package private

A

What are the 4
access modifiers
in java

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is the accessibility of
members with the protected access modifier

A

these members are Accessible within the same package or subclasses

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The order for this is:

  1. Package declaration (if present): Specifies the package to which the class belongs
  2. Import statements (if present): Used to import other classes or packages referenced by the class
  3. Class declaration.

Not maintaining this order will result in a compile-time error.

A

within a class file what is the order that must be maintained

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

these members are
Accessible within the same package

A

what is the accessibility of
members with the default (package private) access modifier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is the accessibility of
members with the private access modifier

A

these members are Accessible only within the same class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

these members are Accessible from anywhere

A

what is the accessibility of
members with the public access modifier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what is the
srtucture of a basic class

A

The structure for this is as follows:

Access_modifier class class_name
{
    Fields
    Constructors
    Getter methods
    Setter methods
    Other methods
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly