Top Posters
Since Sunday
1
New Topic  
miks miks
wrote...
Posts: 474
4 years ago
Analyze the following code.

// Program 1:
public class Test {
public static void main(String[] args) {
Object circle1 = new Circle();
Object circle2 = new Circle();
System.out.println(circle1.equals(circle2));
}
}

class Circle {
double radius;

public boolean equals(Circle circle) {
return this.radius == circle.radius;
}
}

// Program 2:
public class Test {
public static void main(String[] args) {
Object circle1 = new Circle();
Object circle2 = new Circle();
System.out.println(circle1.equals(circle2));
}
}

class Circle {
double radius;

public boolean equals(Object circle) {
return this.radius ==
((Circle)circle).radius;
}
}


▸ Program 1 displays true and Program 2 displays true

▸ Program 1 displays false and Program 2 displays true

▸ Program 1 displays true and Program 2 displays false

▸ Program 1 displays false and Program 2 displays false
Textbook 
Introduction to Java Programming, Comprehensive Version

Introduction to Java Programming, Comprehensive Version


Edition: 10th
Author:
Read 47 times
1 Reply
Replies
Answer verified by a subject expert
johnsykejohnsyke
wrote...
Posts: 406
4 years ago
Sign in or Sign up in seconds to unlock everything for free
More solutions for this book are available here

Related Topics

miks Author
wrote...

4 years ago
I appreciate what you did here, answered it right Smiling Face with Open Mouth
wrote...

Yesterday
Helped a lot
wrote...

2 hours ago
Just got PERFECT on my quiz
New Topic      
Explore
Post your homework questions and get free online help from our incredible volunteers
  891 People Browsing
Related Images
  
 1017
  
 228
  
 600
Your Opinion
What's your favorite coffee beverage?
Votes: 304