Share
Explore BrainMass

Java examples of method overloading and equality checking

Please see the attachment.

Attachments

Solution Preview

1. There are numerous ways to test for equality. == works fine for
primitive types, but not for objects such as strings, etc. Why is
this so? Discuss why == doesn't work when utilizing Strings but
does for integers and doubles.

All object variables are actually "object references". That is, the
variable is not really the object but instead is a reference to the
object. It is possible to have two different variables that refer to
the same object. The == operator performs a "reference equals"
operation. If two different object variables are compared with ==
the result ...

Solution Summary

This solution discusses two Java concepts. First, it explains the concept of comparing two different reference objects. Second, it describes the process of method overloading.

$2.19