Question: For this exercise, you are given 3 Object class objects and 3 Ball class objects. In theory, all three Objects are the same and all

For this exercise, you are given 3 Object class objects and 3 Ball class objects. In theory, all three Objects are the same and all 3 Ball objects are the same, but based on the way they are created and the way that Java evaluates equality, not all three objects will be equal.

Your task is to start by printing out the 6 Object and Ball objects. Remember, the Object class has a toString and since a Ball object extends the Object class, we should see similarities between the Object and Ball class.

After printing them out, you should notice which objects are the same. Write 2 true and false statements for each group, one using == and one using .equals. Will these be the same?

public class TestEquals { public static void main(String[] args) { System.out.println("** Object **"); Object obj1 = new Object(); Object obj2 = new Object(); Object obj3 = obj1; // Print out all three objects

// Print a true statement using 2 objects and ==

// Print a false statement using 2 objects and ==

// Print a true statement using 2 objects and .equals()

// Print a false statement using 2 objects and .equals()

System.out.println("** Ball **"); Ball ball1 = new Ball("Red"); Ball ball2 = new Ball("Red"); Ball ball3 = ball1; // Print out all three objects // Print a true statement using 2 objects and ==

// Print a false statement using 2 objects and ==

// Print a true statement using 2 objects and .equals()

// Print a false statement using 2 objects and .equals()

} }

public class Ball { private String color; public Ball(String color){ this.color = color; } public String getColor(){ return color; } }

For this exercise, you are given 3 Object class objects and 3Ball class objects. In theory, all three Objects are the same and

FILES TestEquals.java 5 points Status: Not Submitted For this exercise, you are given 3 Object class objects and 3 Ball class objects. In theory, all three Objects are the same and all 3 Ball objects are the same, but based on the way they are created and the way that Java evaluates equality, not all three objects will be equal. Your task is to start by printing out the 6 Object and Ball objects. Remember, the object class has a toString and since a Ball object extends the Object class, we should see similarities between the Object and Ball class. Ball.java 1 public class TestEquals 2-{ 3 public static void main(String[] args) 4- { 5 System.out.println("** Object **"); 6 Object obj1 = new ObjectO; 7 Object objz - new Object(); 8 Object obj3 = obj1; 9 10 // Print out all three objects 11 12 13 // Print a true statement using 2 objects and == 14 15 16 // Print a false statement using 2 objects and == 17 18 19 // Print a true statement using 2 objects and .equals 20 21 22 // Print a false statement using 2 objects and .equals 23 24 25 System.out.println("** Ball "); 26 27 28 Ball ball1 = new Ball("Red"); 29 Ball ball2 = new Ball("Red"); 30 Ball ball3 - ball1; After printing them out, you should notice which objects are the same. Write 2 true and false statements for each group, one using == and one using.equals. Will these be the same? Inheritance 9.1 9.2 9.3 9.4 9.5 9.6 9.8 Status: Not Submitted @ 9.7.6: Equal? Save Submit Continue RUN CODE | TEST CASES ASSIGNMENT DOCS GRADE MORE iti FILES TestEquals.java 1 public class Ball 2-{ 3 private String color; 4 5 public Ball(String color){ 6 this.color - color; 7 } 8 9 public String getColor({ 10 return color; 11 3 12} 13 5 points Status: Not Submitted G For this exercise, you are given 3 Object class objects and 3 Ball class objects. In theory, all three Objects are the same and all 3 Ball objects are the same, but based on the way they are created and the way that Java evaluates equality, not all three objects will be equal. Your task is to start by printing out the 5 Object and Ball objects. Remember, the Object class has a toString and since a Ball object extends the Object class, we should see similarities between the Object and Ball class. Ball.java After printing them out, you should notice which objects are the same. Write 2 true and false statements for each group, one using and one using.equals. Will these be the surre?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!