DS Java 2324 3B EN
DS Java 2324 3B EN
1
2. What is the output of this program ?
A. true true
B. false false
C. true false
D. false true
4. Based on this code, the variable "name" can be accessed directly from:
A. any class
B. only the Student class
C. Any class in the package “entities”
D. any class that inherits from the Student class
2
Copy the code onto the exam sheet.
PS-2: Note that all the attributes of all classes have the
"private" access level.
3
1. TODO 1 (1pt): The "Person" class should allow inheritance only for
the "Trainer" and "Member" classes.
Person Class
TODO 1
public................................................ class
Person ................................................................ {
TODO 2
..............................................................................................................................
.......................
TODO 3
..............................................................................................................................
.......................
TODO 4
..............................................................................................................................
.......................
}
.......................................................................................................
....................
4
8. TODO 7 (2pts): Implement salary and trainerId getters and setters
knowing that salary must be greater than or equal to 0 and
trainerId is not empty.
Trainer Class
TODO 5
public.......................................... class
Trainer ..................................................................... {
TODO 6
.............................................................................................................................
........................
TODO 7
.............................................................................................................................
........................
TODO 8
.............................................................................................................................
........................
}
Member Class
TODO 9
5
public.................................... class
Member ............................................................ {
TODO 10
.............................................................................................................................
........................
TODO 11
.............................................................................................................................
........................
TODO 12
.............................................................................................................................
........................ }
Gym Class
TODO 13
private String name;
private .............................. int
CAPACITE_MAX ............................................................;
...........................................................................................................................
........................
6
TODO 14
..............................................................................................................................
........................
TODO 15
public void getStatistics( ) {
..............................................................................................................................
........................ }