aspose file tools*
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
Author

interview question on core java

Bandita Patel
Greenhorn

Joined: Mar 23, 2010
Posts: 25
I have a class Arraylist.java...i 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
Bartender

Joined: May 31, 2011
Posts: 1776
Make your ArrayList.java 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
Sheriff

Joined: Oct 13, 2005
Posts: 38851
    
  23
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: http://aspose.com/file-tools
 
subject: interview question on core java