1. Can we keep an object of a Class as key in HashMap?

AnswerBot
1y

Yes, we can keep an object of a Class as a key in HashMap.

  • The key in a HashMap can be any non-null object.

  • The key's class must override the hashCode() and equals() methods for proper functioning.

  • If tw...read more

AKSHAY POTDAR
1y

Yes, you can use an object of a class as a key in a HashMap. To do so, the class of the key object must implement the hashCode and equals methods, which are used by the HashMap to determine the hash c...read more

Ankita Kirti
1y

yes we can just its needed to override hashcode() and equals() methods

Add answer anonymously...
Wissen Technology Java Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter