0
I could not figure out whats wrong with the below code
public class Cat { String name; int age; public static void main(String[] args) { Cat smudge = new Cat(); System.out.println("Here the program does something for 2 hours..."); smudge.age = 3; smudge.name = "Smudge"; } } Look over this code and try to figure out what's wrong with our program. Our program had a cat with no name or age for 2 hours! I did understand the above statement
5 Answers
0
The original article says something is wrong with the code
0
Its from codegym
0
there are many Cat statements, perhaps you are solving this:
"Create valid cats in an unnatural way: using constructors. Let's create a Cat class and declare five different constructors. The simplest constructor contains one parameter: name. The next has name and age. And we'll add weight to the third. Read about the rest in the task conditions."
so learn what constructor of object in java is