Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a class with default access modifier.
Java
class [1] { void display() { System.out.println("Hello"); } }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
2fill in blank
mediumComplete the code to declare a method with default access modifier inside a class.
Java
class Test { [1] void show() { System.out.println("Show method"); } }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
3fill in blank
hardFix the error in the code by choosing the correct access modifier for the class to have default access.
Java
[1] class Sample { void test() { System.out.println("Test method"); } }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
4fill in blank
hardFill both blanks to declare a variable and a method with default access modifier inside a class.
Java
class Example { [1] int number; [2] void display() { System.out.println(number); } }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
5fill in blank
hardFill all three blanks to declare a class, a variable, and a method with default access modifier.
Java
[1] class Data { [2] int value; [3] void print() { System.out.println(value); } }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
