Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a protected variable named data.
Java
protected [1] data;🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
2fill in blank
mediumComplete the code to declare a protected method named showData that returns nothing.
Java
protected [1] showData() { }🎯 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 access modifier for the method display so it can be accessed by subclasses.
Java
[1] void display() { System.out.println("Hello"); }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
4fill in blank
hardFill both blanks to declare a protected constructor for class Example.
Java
class Example { [1] [2]() { } }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
5fill in blank
hardFill all three blanks to create a protected method named calculate that returns an integer and takes an integer parameter named value.
Java
protected [1] calculate([2] [3]) { return value * 2; }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
