This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes interview question on core java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "interview question on core java" Watch "interview question on core java" New topic

interview question on core java

Bandita Patel

Joined: Mar 23, 2010
Posts: 25
I have a class want to make my class to behave as Set...then what need to do? What changes i have to do in my class.....
kindly reply..
John Jai

Joined: May 31, 2011
Posts: 1776
Make your implement the Set interface or just extend the HashSet class
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Bandita Acharya wrote:then what need to do?

You need to understand the difference between List and Set Abstract Data Structures!
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38107
Did they really ask you that question in an interview? Lists and Sets are like bicycles and boats. The interviewer is asking you to ride your bicycle across the lake. Or maybe to sail the boat up the street.
Gaurav Raje
Ranch Hand

Joined: Jul 23, 2010
Posts: 136
i believe that the interviewer wants to add the condition of uniqueness... So the answer would be
" I will modify (or override if you are making a subclass) the add method of the data structure to add a contains check before adding. If the object is present.. return false and not add... else add
I agree. Here's the link:
subject: interview question on core java
Similar Threads
Not Compiling > problelm
Unable to run servlet on my machine
a certain bug i cant understand..
ServletContext, again
what is the default return value for doStartTag