CodeGym /Courses /Java Core /Bonus task | Lesson 12 | Level 5

Bonus task | Lesson 12 | Level 5

Java Core
Level 5, Lesson 12
Available

"Hey, soldier!"

"Good day, Captain!"

"I've got awesome news for you. Here are some exercises to reinforce your skills. Do them every day and your skills will grow at an insane speed. They were created especially for IntelliJ IDEA."

16
Task
Java Core, level 5, lesson 12
Locked
Different methods for different types
Different methods for different types
4
Task
Java Core, level 5, lesson 12
Locked
Brain training
Brain training
8
Task
Java Core, level 5, lesson 12
Locked
OOP: Method overloading
OOP: Method overloading
16
Task
Java Core, level 5, lesson 12
Locked
Reinforce the singleton pattern
Reinforce the singleton pattern
8
Task
Java Core, level 5, lesson 12
Locked
Overloading constructors
Overloading constructors
8
Task
Java Core, level 5, lesson 12
Locked
Order of loading variables
Order of loading variables
8
Task
Java Core, level 5, lesson 12
Locked
File in a static block
File in a static block
8
Task
Java Core, level 5, lesson 12
Locked
Debug, debug, and again debug
Debug, debug, and again debug
16
Task
Java Core, level 5, lesson 12
Locked
Request parser
Request parser
8
Task
Java Core, level 5, lesson 12
Locked
OOP: The Euro is money too
OOP: The Euro is money too

"Those previous exercises were for rookies. I've added some more advanced bonus exercises for the old-timers. Just for veterans."

8
Task
Java Core, level 5, lesson 12
Locked
Mastering the static block
Mastering the static block
8
Task
Java Core, level 5, lesson 12
Locked
Template pattern
Template pattern
8
Task
Java Core, level 5, lesson 12
Locked
Factorial
Factorial
Comments (39)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
17 September 2025
The IDE can trip you up in the last exercise because the imports are hidden by default when you first open it up. One of those imports is very important and it's easy to (wrongly) assume that the test cases will be low enough to not require it. It's not an issue in the browser because obviously the imports are not automatically hidden there, and just knowing that the important one is there is the difference between solving the exercise in one go and getting a slight headache.
Hoa Nguyen Level 15, Australia Expert
9 February 2022
I have no clue why we need the modifier "volatile" in private static volatile Moon instance; I also don't understand the use of "synchronized" in the method. Not a good surprise. public static Moon getInstance() { if (instance == null) { synchronized (Moon.class) { if (instance == null) { instance = new Moon(); } } } return instance; }
Jonaskinny Level 25, Redondo Beach, United States
10 March 2022
volatile so it would not be cached (best practice but not key to this task) synchronized so if two threads come in, first thread checks if null, if it is, it synchronizes (at the class level since this is static), allowing the first thread to instantiate before releasing the lock, so the second thread cant instantiate a second instance before the first instance shows as not null on subsequent threads.
DarthGizka Level 24, Wittenberg, Germany
4 June 2021
task1521 (Different methods for different types) caveat: this one really takes the biscuit... Ignore anything that the task descriptions says about what the new info functions should/might print. The output must be *exactly* like that of the existing info function - down to the erroneous blank before the comma - except for the substitution indicated by the formal requirements (i.e. the bulleted list items).
remote87 Level 18, Sofia, Bulgaria
16 February 2021
YEAH!!!! Solved "Different methods for different types" in just 3 hours and just in 9 tries! I consider myself one of the smartest people on the universe!!! P.S. I love this feeling of solving a complex task and all the excitement after that! Please, do excuse me for being so ... ah, you know what I mean, I'm just too happy! :D
remote87 Level 18, Sofia, Bulgaria
16 February 2021
aaaaaand, saw Codegym's solution.... It seams I'm not that smart as I thought of myself pahahahah :D I wonder, will I be able to think like that anytime in the future?!
Maxim Raitin Level 20, Tomsk, Russian Federation
17 May 2021
Man, I read first time your message that you solved all of this tasks in 3 hours.. I was so frustrated..
Oliver Heintz Level 18, Mustang, United States
24 January 2021
I have now officially calculated 150 factorial. Thanks BigInteger. You make life swell.
20 December 2020
for me the factorial was brutal as it started spewing out negative numbers...but lots of fun and lots of learning, awesome.
Andrei Level 1
10 December 2020
Oh man, I spent about 3 days (4 h / day) on "Different methods for different types" and "Request Parser" .... man.. I'm telling you, these must have been the most brutal problems for me.. I just couldn't wrap my head around them, around CodeGym's requirements. If it wouldn't have been for long conversation with Nouser and Misiu in the help section for each problem I don't know if I would have been able to solve them so quickly. But the most important thing, I DID NOT GIVE UP. I just kept on trying, day after day, even if at one point I just dreaded trying to start and solve the problems. So, I believe you can do it, you just gotta keep pushin at it, keep trying. Best of luck and NEVER give up!
whoseunassailable Level 28, India, India
11 March 2022
i kind of felt disappointing after a hour and half. I then looked up to the solution and noticed my solution was exactly the same as codegym's. The only thing i didn't use was the try and catch block which i was gonna use but then decided to solve in some other way. I thought i am dumb enough to solve it.
Anonymous #10782038 Level 24, United States of America
15 April 2024
waste of time to spend that long on one problem. There is no shame in learning from the answer after you spend a decent amount of time on it initially.
Chandan Thapa Level 22, Dubai, United Arab Emirates
8 December 2020
learned a lot from these courses. just a thought -- sometimes if you have the urge to peek over other's solved answers to validate if you are going the right direction with your own code then I think probably you must not do that unless you are really stuck(check multiple answers in this case). Just do the way you are doing without looking until you reach the edge and ofcourse google search is very useful. Guilty is charged -- I was the victim of the above in 2 of the tasks above, just to find out that i was going the right way, i would have felt much better if i had solved those two without wandering around. Enjoyed it a lot!! :)
Lawson Level 29, Lagos, Nigeria
29 August 2020
Apart frm me , who else also copied and paste some of the answers? let me know whether to stop learning at this point
Artur Level 22, Moorends, United Kingdom
14 November 2020
i did some i admit but can't really choose if did so because of lazyness or because was too tired of trying... i do regret tho i might have omitted some parts that could teach me something important..
Clint Level 22, cincinnati, united states
27 November 2020
most definitely did
Agent Smith Level 38
29 August 2020
Had a lot of fun with Request parser task. It is quite convenient to store parameters as key-value pairs. But if you do it the same way, make sure to use LinkenHashMap, because order matters in this task.
Jonaskinny Level 25, Redondo Beach, United States
10 March 2022
You can also just build it in-line while processing, using only what is imported. I have been keeping solutions to only use what is imported (and java.lang default import of course) and order takes care of itself.