Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a private variable named age of type int.
Java
private [1] age;🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
2fill in blank
mediumComplete the code to create a private method named getAge that returns an int.
Java
private [1] getAge() { return age; }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
3fill in blank
hardFix the error in the code by completing the blank to access the private variable name inside the class.
Java
public String getName() { return this.[1]; }🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
4fill in blank
hardFill both blanks to create a private constructor that initializes the private variable id.
Java
private [1]([2] id) { this.id = id; }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
5fill in blank
hardFill all three blanks to create a private setter method named setScore that updates the private variable score.
Java
private [1] setScore([2] score) { this.[3] = score; }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
