Interview Questions and Answers for 'Appknox' | Search Interview Question -

Search Interview Questions

 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text


Interview Questions and Answers for 'Appknox' - 3 question(s) found - Order By Newest

Very frequently asked in different variations. Frequently asked in Deloitte ( 2 feedback ) , HCL Tech ( 3 feedback ), TCS and Coginizant (CTS)
  Q1. Explain the scenerios to choose between String , StringBuilder and StringBuffer ?


What is the difference between String , StringBuilder and StringBuffer ?
Core Java
Ans. If the Object value will not change, use String Class because a String object is immutable.

If the Object value can change and will only be modified from a single thread, use StringBuilder because StringBuilder is unsynchronized(means faster).

If the Object value may change, and can be modified by multiple threads, use a StringBuffer because StringBuffer is thread safe(synchronized).

  Sample Code for String

  Sample Code for StringBuffer

  Sample Code for StringBuilder

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   string class   string   stringbuilder   stringbuffer   String vs StringBuffer   String vs StringBuilder   String vs StringBuilder vs StringBuffer   StringBuffer vs stringBuilder     Asked in 29 Companies      basic        frequent

Try 3 Question(s) Test

Related Questions

  Difference between == and .equals() ?
  Why is String immutable in Java ?
  Why Char array is preferred over String for storing password?
  What are different ways to create String Object? Explain.
  What is a String Pool ?
 How does making string as immutable helps with securing information ? How does String Pool pose a security threat ?
 How is string object immutable if we can concat a string to it ?
  What is StringJoiner ?
 Which of the following is false about main method ?

a. It should be declared public and static
b. it should have only 1 argument of type String array
c. We can override main method
d. We can overload main method

 Q2. Difference beween HashSet and TreeSet ?Core Java
Ans. 1. HashSet doesnt maintain its elements in any specific order and is all random whereas TreeSet maintains elements in natural order 9 order defined by the equals method of TreeSet element type )

2. TreeSet doesnt allow null elements whereas HashMap does.

3. As TreeSet orders elements and is hence insertion is comparatively slower.

4. HashSet performs basic operations like add(), remove(), contains(), size() etc. in a constant size time. A TreeSet performs these operations at the order of log(n) time.

5. HashMap in Java internally backs a HashSet. A NavigableMap backs a TreeSet internally.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     collections  hashset  treeset  set   hashet vs treeset     Asked in 4 Companies      Basic        frequent

Try 1 Question(s) Test

Related Questions

  Difference between TreeMap and HashMap ?
  What is reflection ?
  What is comparator interface used for ?
  If I try to add Enum constants to a TreeSet, What sorting order will it use ?
  Which of the following collections stores its elements in insertion Order ?

a. HashMap
b. TreeMap
c. LinkedHashMap
d. LinkedMap
  Which are the sorted collections ?
  Which of the following collection maintain its elements in Natural Sorted order ?
 What is a binary tree ?
  What are the phases of the JSP life cycle ?

  Q3. Difference between Vector and ArrayList ?Core Java
Ans. Vectors are synchronized whereas Array lists are not.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   basic interview question   vector   arraylist   collections   synchronization   vector vs arraylist     Asked in 35 Companies      basic        frequent

Related Questions

  What is the difference between ArrayList and LinkedList ?
 If you are given a choice to use either ArrayList and LinkedList, Which one would you use and Why ?
  Difference between HashMap and Hashtable?
  Difference between TreeMap and HashMap ?
  Can you provide some implementation of a Dictionary having large number of words ?
  Will this code give error if i try to add two heterogeneous elements in the arraylist. ? and Why ?
  What is a ConcurrentHashMap ?
 Collections.sort can only be performed on ..

a. Set
b. List
c. Map
d. Any Collection implementation
 Why HashTable has been deprecated ?
 Difference beween HashSet and TreeSet ?

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: