what is difference betwwen hashmap and hashtable ?
Answers were Sorted based on User's Feedback
Answer / deep pratap singh
HashMap HashTable
1> Not Synchronized Synchronized
2> can contain null cann't
You may also make HashMap Synchronized using generic
methods. Using Hashtable is bad habit. Try to avoid it.
| Is This Answer Correct ? | 10 Yes | 2 No |
Answer / ravikiran
hashmap allows one null key and multiple null values.
hashtable doesn't allow null elements
hashmap is not synchronized
hashtable is snchronized
hashmap is not legacy
hashtable is legacy
| Is This Answer Correct ? | 6 Yes | 0 No |
Answer / ajay yadav
Hash Map allows null values.
Hash Table dont allows null values.
| Is This Answer Correct ? | 4 Yes | 0 No |
Answer / javablossom
The Iterator is used in the hashmap is fail-safe and
whereas the Enumerator used in hashtable is not fail-safe.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / sekhar
Both class are under map interface.But hash table is
synchronized.hashMap is not.we can explictly synchronize
hash map by using the method
Collections.synchronizedMap(Hash Map);
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / kvn
Hash map contains null values,but hash table does not.
| Is This Answer Correct ? | 1 Yes | 3 No |
What is the difference between import java.util.date and java .util?
What is the default value of float and double datatype in java?
What does isempty () do in java?
Question 5 [15] Consider the following classes, illustrating the Strategy design pattern: import java.awt.*; abstract class Text { protected TextApplet tA; protected Text(TextApplet tApplet) { tA = tApplet; } abstract public void draw(Graphics g); } class PlainText extends Text { protected PlainText(TextApplet tApplet) { super(tApplet); } public void draw(Graphics g) { g.setColor(tA.getColor()); g.setFont(new Font("Sans-serif", Font.PLAIN, 12)); g.drawString(tA.getText(), 20, 20); } } class CodeText extends Text { protected CodeText(TextApplet tApplet) { super(tApplet); } public void draw(Graphics g) { g.setColor(tA.getColor()); g.setFont(new Font("Monospaced", Font.PLAIN, 12)); g.drawString(tA.getText(), 20, 20); } } public class TextApplet extends java.applet.Applet { protected Text text; protected String textVal; protected Color color; public String getText() { return textVal; } public Color getColor() { return color; } public void init() { textVal = getParameter("text"); String textStyle = getParameter("style"); String textColor = getParameter("color"); if (textStyle == "code") text = new CodeText(this); else text = new PlainText(this); if (textColor == "red") color = Color.RED; else if (textColor == "blue") color = Color.BLUE; else color = Color.BLACK; } public void paint(Graphics g) { text.draw(g); 10 } } The Text class is more complicated than it should be (there is too much coupling between the Text and TextApplet classes). By getting rid of the reference to a TextApplet object in the Text class and setting the colour in the paint() method, one could turn the Text class into an interface and simplify the strategy classes considerably. 5.1 Rewrite the Text and PlainText classes to do what is described above. (6) 5.2 Explain the consequent changes that are necessary to the TextApplet class. (4) 5.3 Write an additional strategy class called FancyText (to go with your simplified strategy classes) to allow fancy text to be displayed for the value "fancy" provided for the style parameter. It should use the font Font ("Serif", Font.ITALIC, 12). (3) 5.4 Explain what changes are necessary to the TextApplet class for this. (2)
What is the use of static keyword in "public static void main()"
10 Answers College School Exams Tests, Infosys, Six Dee Telecom,
What is tcp ip in java?
What is the alternate of 'Inheritance' ?
Q1.A. Write note on “The class path Environment Variable”? B. Which are different kinds of source code? Q2.A. How to create an interface? B. Why convert an applet to an application? Q3.A. How to use Media tracker Class. B. How to use string tokenizer class. Q4 A. Explain the overview of UDP messaging. B. Difference between SQL Exception class and SQL Warning class. Q5. A. How to create com object in Java? B. Write short notes on “The properties class” Q6. A. When object is created and destroyed? B. Explain the JDB in depth & command line. C. Write short notes on Web Sites.
2 Answers iGate, Seed Infotech,
What is assembly condition codes?
what is the difference between preemptive scheduling and time slicing? : Java thread
my method "abc" return array of interface "xyz" and "pqr" is abstract class implements abc and class "jkl" extends pqr My problem 1) when i call abc it retrun array xyz how can i do this hint xyz refer_xyz = new jkl(); but i can't create array. 2)I want to access method of jkl using reference of xyz??
What is a modifier?