Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Review Java OO principles, specifically the idea that all Java classes are subclasses of the Object class , and thus must have all the methods
-
Review Java OO principles, specifically the idea that all Java classes are subclasses of the Object class, and thus must have all the methods of the Object class even if they don't show up in the Java code for the class. See S&W page 101. You can see the Object class API (and any other standard class) by following the link "JDK API" on the class web page under Resources. Choose Object in the pane titled All Classes, and the API will be displayed on the right.
- What are the four most important Object methods? (Hint: their names start with e, h, g, and t). Because all objects have these methods, we can use HashSet to contain almost any set of objects (but we'll stick to sets of similar-type objects in our work).
- Show equals in use by writing one if () that checks whether s String s is equal to a String t, character by character. Explain what this comparison is doing if s = abc and t = abx. Compare this to what happens in if (s == t).
- Find the hashCode and toString values for String s = xyz. Also for the Integer of value 8.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started