undefined

Final tasks

Java Syntax
Level 6 , Lesson 11
Available

"Hello, soldier!"

"Hello, Captain Squirrels, sir!"

"I have great news for you. Here are some exercises to reinforce your skills. Work on them every day, and your competence will grow exponentially. They were specially designed for IntelliJ IDEA.

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

undefined
5
Task
Java Syntax, level 6, lesson 11
Locked
Cat and statics
The sun rises. The tasks get more complicated: let's study the static keyword. This time, we need to create a static variable catCount and a constructor in the Cat class, i.e. public Cat(). Each time a cat (new Cat object) is created, increment the static variable catCount by 1. We need to create ten cats and display the value of the variable catCount on the screen.
undefined
10
Task
Java Syntax, level 6, lesson 11
Locked
Static cats
A static cat is every cat's cat. So, in this task let's add a static variable cats to the Cat class. Each time a new cat (new Cat object) is created, let it be added to the variable cats. We need to create 10 Cat objects. Then the printCats method should display all the cats on the screen.
undefined
2
Task
Java Syntax, level 6, lesson 11
Locked
Feng Shui and statics
An expert in feng-shui programming looked at the code for a few seconds, lifted one eyebrow, and nodded while solemnly saying: "I found an error in the location of the modifiers in this code. You need to rearrange one static modifier. Then everything will be feng shui. The example will compile. Harmony will be restored".
undefined
5
Task
Java Syntax, level 6, lesson 11
Locked
Minimum number of statics
Warming up the brain is useful, and this is done best with puzzles. But because we're programmers, we put puzzles right into the code. Here you go: for this task, you need to place the minimum number static modifiers necessary to make the code start working and the program complete successfully.
undefined
5
Task
Java Syntax, level 6, lesson 11
Locked
Notepad for new ideas
Great ideas need to be written down or they can be forgotten very quickly. To help with this, in the Solution class, create a static Idea class. Give it a public String getDescription() method that returns any non-empty string. Then create a static public void printIdea(Idea idea) method that displays a description of the idea.
undefined
2
Task
Java Syntax, level 6, lesson 11
Locked
KissMyShinyMetalRearActuator
On Planet Wild Robots, nobody is taught to write or program. That's why when Robot A was taken from his natural environment and moved to a space ship, it turned out he couldn't even sign a contract. Let's help Robot A: create a class called KissMyShinyMetalRearActuator for signing contracts.
undefined
2
Task
Java Syntax, level 6, lesson 11
Locked
Three static name variables
If static variables are not abused, they are extremely helpful. In general, they need to be understood, cherished and tenderly cared for. Now you get code where some classes have already been implemented. Your task is to add three public static variables to the code: String Solution.name, String Cat.name, String Dog.name.
undefined
2
Task
Java Syntax, level 6, lesson 11
Locked
Fixing the mistakes of youth
Sometimes a coder works on a project and does his best. He opens someone else's module and finds that not only does it not work correctly, but it doesn't even compile. This can't be avoided at companies with more than one coder. That's why you need to learn to read and debug others' code from your earliest days as a fledgling programmer. Make this program display the maximum of the two entered numbers.
undefined
10
Task
Java Syntax, level 6, lesson 11
Locked
Cat relations
Finished task: A cat has a name and a mother. Create a class that reflects this. Create two objects: a daughter cat and a mother. Display them on the screen. New task: Each cat has a name, a father, and a mother. Edit Cat so that it reflects these relationships. Create 6 objects: grandfather (the father's father), grandmother (the mother's mother), father, mother, son, daughter.
undefined
10
Task
Java Syntax, level 6, lesson 11
Locked
Ascending numbers
Perhaps you've already heard about the ordered isomorphs from Planet Linear Chaos. You know, the ones who invented every sorting technique? Today we've received a task from them: the user enters 5 numbers from the keyboard, the method sorts the numbers in ascending order, and then another method displays them on the screen. Are you up to the challenge? If so, maybe you should visit Linear Chaos!
Comments (61)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
Khong. Ph. Level 8 Chiangrai Thailand
28 March 2021
How I do if I don't use Array?
Gaelle Gilles Level 12 New York City United States
21 December 2020
What is bothering me about these exercises is that they have to be written in a certain way. I am studying computer science in grad school, so I've created many classes before and so I have a certain style of writing them. When writing a class here, I get the solution wrong when I know they are right.
David Close Level 17 London United Kingdom
4 November 2020
gotta love this
Peter Level 7 Enschede Netherlands
20 October 2020
Really nice exercises again. Nice to see the introduction of the ArrayList, however they where already saving my ass few tasks ago so not completely new anymore.
Mihai Bone Level 8 Bucharest Romania
14 October 2020
When catFather meet catMother they did plan to give me maximum damage. I'm afraid to click on next one😢
Rajesh R Level 7 Toronto Canada
8 October 2020
Hint - loop through the elements of array to display each number in a new line
Laura Level 7 Lübeck Deutschland
4 October 2020
Never give up guys
Karas Level 19 Tampa United States
4 September 2020
Also for array list:

Collections.sort(arrayList)
dont forget though:

import java.util.*;
Agent Smith Level 38
14 August 2020
There are many useful built-in classes and methods in Java, for example:

Arrays.sort(someArray);
BLANC Level 12 Paris France
31 May 2020
I drank 3 bottles of red wine because of this arraylist!!!!!