Question: CSC435 Object Oriented Programming 2. What will happen when you attempt to compile and run the following code? Fix the errors. public class Cat extends

CSC435 Object Oriented Programming 2. What will happen when you attempt to compile and run the following code? Fix the errors. public class Cat extends Animal protected int tagNumber; public Cat (int tn) { tagNumber = tn; if (haircolor.equals("unknown")) hairColor = "brown"; } public int getTagNumber() { return tagNumber; ) 11 + haircolor + " hair color and tag public String toString() { return "I am a Cat with number " + tagNumber; } class Animal { private String hairColor; public Animal() { hairColor = "unknown"; } public Animal (String hc) { hairColor = hc; } public String getHairColor() { return hairColor; } public String toString() { return "I am an Animal with } + hairColor + " hair color."; CSC435 Object Oriented Programming 2. What will happen when you attempt to compile and run the following code? Fix the errors. public class Cat extends Animal protected int tagNumber; public Cat (int tn) { tagNumber = tn; if (haircolor.equals("unknown")) hairColor = "brown"; } public int getTagNumber() { return tagNumber; ) 11 + haircolor + " hair color and tag public String toString() { return "I am a Cat with number " + tagNumber; } class Animal { private String hairColor; public Animal() { hairColor = "unknown"; } public Animal (String hc) { hairColor = hc; } public String getHairColor() { return hairColor; } public String toString() { return "I am an Animal with } + hairColor + " hair color
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
