File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 46410
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
It's not a secret anymore!