"Hello, Amigo!"
4
Task
Java Core,
level 5,
lesson 9
Locked
Static modifiers: part 1
In a static block, initialize labels with 5 different key-value pairs. The Solution class should have only one method (main), where you must also declare a static Map field labels. This field must be populated with 5 different key-value pairs in a static block.
8
Task
Java Core,
level 5,
lesson 9
Locked
Static modifiers: part 2
In a static block, read two int variables A and B from the console. Don't forget about the IOException that must be handled in the catch block. Finally, use the close() method to close the input stream.
8
Task
Java Core,
level 5,
lesson 9
Locked
Default values
In this task, you need to create 7 public fields for a class. Be sure they are initialized with default values (int intVar, double doubleVar, Double DoubleVar, boolean booleanVar, Object ObjectVar, Exception ExceptionVar, and String StringVar). In the main method, display their values in the specified order.
8
Task
Java Core,
level 5,
lesson 9
Locked
Static modifiers and exceptions
Let's throw some exceptions! In a static block, throw an Exception so that the class doesn't load and you see an error message instead of the value of the variable.
4
Task
Java Core,
level 5,
lesson 9
Locked
Static modifiers and kittens
Let's introduce cats to the world of static blocks. First, in the Solution class, we'll create a Cat class with a public String field name, but without a constructor with parameters. Then in a static block, we'll create a Cat object and display the created cat's name on the screen.
GO TO FULL VERSION