"Này, quân nhân!"
"Chúc một ngày tốt lành, thuyền trưởng!"
"Tôi có một tin tuyệt vời dành cho bạn. Đây là một số bài tập để củng cố kỹ năng của bạn. Hãy thực hiện chúng hàng ngày và kỹ năng của bạn sẽ phát triển với tốc độ chóng mặt. Chúng được tạo riêng cho IntelliJ IDEA."
"Những bài tập trước đó là dành cho tân binh. Tôi đã thêm một số bài tập bổ sung nâng cao hơn cho những người già. Chỉ dành cho những người kỳ cựu."
16
Nhiệm vụ
Java Core, mức độ, bài học
Different methods for different types
So, polymorphism. You haven't forgotten about it, have you? Good. Then let's complete the following task: Read data from the console until the word "exit" is entered. For each value (except "exit"), call the print method. The correct print method depends on the value. For example, if the value contains a period, then use the print method for Double. If the value is a number between 0 and 128, then use the method for short.
4
Nhiệm vụ
Java Core, mức độ, bài học
Brain training
Find the error in the logic: Duck should correctly implement the CanMove interface. Fix the error so you get the correct result.
8
Nhiệm vụ
Java Core, mức độ, bài học
OOP: Method overloading
Overload the Tree class's info(Object s) method twice to get 3 methods: info(Object s), info(Number s), and info(String s). Then study the info(Object s) method and create similar functionality in the new methods. For example, the result for the info(Number s) method might be: "Tree No. 123, Number method, parameter Short.
16
Nhiệm vụ
Java Core, mức độ, bài học
Reinforce the singleton pattern
Let's delve into the singleton pattern by considering the sun and planets of the solar system. First, do an Internet search and find some example of "lazy initialization" using the singleton pattern. Create three singleton classes "in its likeness and image": Sun, Moon and Earth. Then implement the Planet interface in them. And do a couple other operations.
8
Nhiệm vụ
Java Core, mức độ, bài học
Overloading constructors
In this task, we need to create the Solution class and its descendant SubSolution. We need to create constructors for this descendant and fix their access modifiers so that we get three constructors with different modifiers (except private).
8
Nhiệm vụ
Java Core, mức độ, bài học
Order of loading variables
Time for a useful debugging task. You have code you need to dig into: figure out what gets initialized and in what order. You can do this using the IntelliJ IDEA debugger and breakpoints. Then fix the initialization order so you get a specific result.
8
Nhiệm vụ
Java Core, mức độ, bài học
File in a static block
Initialize the variable Statics.FILE_NAME to the full path to a data file that contains several lines. Then, in the static block, read all the lines from the file named Statics.FILE_NAME, and add them separately to the List lines.
8
Nhiệm vụ
Java Core, mức độ, bài học
Debug, debug, and again debug
Again and again, we search for other people's mistakes and correct them... That's our lot in life as programmers. Our program again displays something wrong: An bug has crept in (just one!). Find it and neutralize it! Use the IntelliJ IDEA debugger to do this.
16
Nhiệm vụ
Java Core, mức độ, bài học
Request parser
Read a URL from the console. Then display a space-delimited list of all the parameters (The parameters follow the "?" and are separated by "&", e.g. "lvl=15"). The URL contains at least 1 parameter. If the obj parameter is present, pass its value to the relevant alert method.
8
Nhiệm vụ
Java Core, mức độ, bài học
OOP: The Euro is money too
Correct the Euro class to avoid a StackOverflowError. And, strange as it may seem, the Euro should inherit the Money class, which should implement the getAmount method.
8
Nhiệm vụ
Java Core, mức độ, bài học
Mastering the static block
Let's create Plane and Helicopter classes that implement the CanFly interface. Then in the Solution class's static method, we need to read a String from the console. If it's equal to "helicopter" ("plane"), we'll assign a Helicopter (Plane) object to the static CanFly field result. In the static block, initialize the CanFly field result by calling the reset method.
8
Nhiệm vụ
Java Core, mức độ, bài học
Template pattern
Let's create an algorithm for baristas in the DrinkMaker class. It will choose a suitable cup, add ingredients, and pour liquid. Also, we'll inherit DrinkMaker to create highly specialized algorithms for tea and latte.
8
Nhiệm vụ
Java Core, mức độ, bài học
Factorial
On Planet Linear Chaos, infants are expected to find the factorial of two-digit numbers. Well, we'll behave like adults, like programmers, and write a method that calculates factorials up to the entered number.