CodeGym /Courses /Java Syntax /Practice creating objects

Practice creating objects

Java Syntax
Level 5 , Lesson 5
Available

"Hi, Amigo! Here are some tasks that involve creating classes and objects."

Comments (76)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
larsintech Level 16, Switzerland Expert
8 December 2024
Really unclear instructions for Cat carnage (3) in terms of comparison
6 September 2025
Not very unclear, just rather dumb. The intended comparison (every attribute matters equally, the cat with a higher attribute gets 1 point with neither getting any in the event of a tie) is the only one that's accepted, and without knowing about Integer.compare the solution ends up being quite long and convoluted compared to all the other tasks in this lesson. Terrible problem overall.
24 February 2023
The (Cat anotherCat) was new for me.
Michael Amann Level 22, United States of America, United States
13 April 2022
Where did Integer.compare come from? 🤯
Anonymous #10948087 Level 6, Spain
8 March 2022
No la entiendes porque no se ha explicado. En Java (y en otros lenguajes como C, C++ y C#) hay un operador que se llama ternario: (condicion) ? valor_si_verdadero : valor_si_falso; Es una especie de if/else comprimido. Si se cumple la condición, se ejecuta valor_si_verdadero; en caso contrario, se ejecuta valor_si_falso. Espero que te ayude.
Mindre Mercedes Bautista Level 6, Rome, Italy
8 March 2022
gracias. ahora lo entiendo.
9 July 2021
I don't like that you don't have to create classes here. I know the title of the page says "Practice creating objects" but in the individual tasks it says "Create the Person class." but the class is already written. In the previous lessons one had to re-type a whole program just for practice. I think it's easy enough as of now to write the class as well. The average number of attempts for this task is 1.18 and it reflects that it's too easy :).
Jonaskinny Level 25, Redondo Beach, United States
10 February 2022
Unsolicited advice --> I created a class demonstrating all the == between various string constructs, decimal/octal/binary/unicode ... why not give yourself simple tasks like creating the class in another editor for each assignment? Also, I'm not a fan of IDE reliance, so maybe couple that practice with using commandline, jdk and a text editor only. Write sh or bat(if on windows) to set CLASSPATH and JAVA_HOME and execute your programs using ant etc. There is a ton you can do along the way if you think it's too easy. You'll also get better at tailing logs etc so when you get a position you will not be reliant on an IDE or a web-based compiler ;)
Oleg Level 8, Kiev, Ukraine
24 March 2021
what is line "return score>2" does mean?
Angelo Tratsis Level 8, Boston, United States
15 April 2021
great question. You don't have to write if statement. Automatically if its true will return true otherwise false
Mrrobot993 Level 9, Italy
15 October 2021
Means that (score>2) == true? return true
gabe Level 6, Greenville, United States
3 November 2020
why does sally have so many cats?
freewilly Level 5, Philadelphia, United States
2 November 2020
char datatypes expect a single quotation 2-bit value, e.g. 'm' String datatypes expect a double quotation, e.g. "m"
Libby Level 2, United Kingdom
4 January 2021
Thanks for this information
Chung Kang Level 6, Houston, United States
27 August 2020
I got confused with Character vs char
Angel Li Level 9, Fremont, United States
16 October 2020
Character is the "wrapper" class of char. You use wrapper classes to make objects and when declaring the generics of stuff like Maps, Arrays, etc.
Agent Smith Level 38
10 August 2020
If you have trouble with Implement the fight method, check how your code handles these additional cases: 1) If both cats have exactly same values. 2) If cat1 has 2 better values and 1 worse than cat2. 3) If cat1 has 1 better value and 2 worse than cat2.