QUESTION 2 Consider the following implementation of hashCode(), in a class where str is a String: public int hashCode ()

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

QUESTION 2 Consider the following implementation of hashCode(), in a class where str is a String: public int hashCode ()

Post by answerhappygod »

Question 2 Consider The Following Implementation Of Hashcode In A Class Where Str Is A String Public Int Hashcode 1
Question 2 Consider The Following Implementation Of Hashcode In A Class Where Str Is A String Public Int Hashcode 1 (36.7 KiB) Viewed 34 times
QUESTION 2 Consider the following implementation of hashCode(), in a class where str is a String: public int hashCode () { int hash 0; int n str.length; for (int i=0; i<n; i++) { hash 31 * hash + str.charAt(i); } return hash; } If str="try": what does hashCode() return? [a] Note the following ASCII codes: t' is 116 'Tis 114 'Y' is 121
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply