Core Java - Interview Questions and Answers for 'Java.util' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

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

   



Core Java - Interview Questions and Answers for 'Java.util' - 15 question(s) found - Order By Newest

Frequently asked in CTS ( Based on 2 feedback )
  Q1. What is the difference between comparable and comparator in java.util pkg?Core Java
Ans. Comparable interface is used for single sequence sorting i.e.sorting the objects based on single data member where as comparator interface is used to sort the object based on multiple data members.

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

   Like         Discuss         Correct / Improve     java   java.util   comparable   comparator   collections     Asked in 23 Companies      basic        frequent


 Q2. What's wrong with this code ?

public static void main(String[] args) {
String regex = "(\\w+)*";
String s = "Java is a programming language.";

Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(s);
while (matcher.next()) {
System.out.println("The e-mail id is: " + matcher.group());
}
}
Core Java
Ans. matcher.find() should have been used instead of matcher.next() within while.

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

   Like         Discuss         Correct / Improve     java   regex   pattern.matcher   java.util   coding   code


 Q3. Which of the following is not a valid java.util.Locale initialization ?

a. new Locale ()
b. new Locale ( String language )
c. new Locale ( String language , String country )
Core Java
Ans. a i.e new Locale()

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

   Like         Discuss         Correct / Improve     java   locale   java.util


 Q4. Which of the following is not a valid NumberFormat initialization ?

a. NumberFormat.getInstance()
b. NumberFormat.getDateInstance()
c. NumberFormat.getCurrencyInstance()
d. NumberFormat.getNumberInstance()
Core Java
Ans. b i.e NumberFormat.getDateInstance()

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

   Like         Discuss         Correct / Improve     java   java.util.numberformat


 Q5. Which of the following code is correct ?

a. Date date = DateFormat.newInstance(DateFormat.LONG, Locale.US).parse(str);

b. Date date = DateFormat.newInstance(DateFormat.LONG, Locale.US).format(str);

c. Date date = DateFormat.getDateInstance(DateFormat.LONG, Locale.US).parse(str);
Core Java
Ans. c

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

   Like         Discuss         Correct / Improve     java   java.util   date   dateformat


 Q6. Name few Date and Time Classes you have used in your projects ?
Ans. http://www.buggybread.com/2015/02/java-util-date-time-classes-and.html

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

   Like         Discuss         Correct / Improve     java   util   java.util.date   time


 Q7. Name few Calendar related classes and Interfaces ?
Ans. http://www.buggybread.com/2015/02/java-util-calendar-classes-and.html

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

   Like         Discuss         Correct / Improve     java   util   java.util   calendar


 Q8. Name few Locale classes and interfaces ?
Ans. http://www.buggybread.com/2015/01/java-locale-classes-and-interfaces.html

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

   Like         Discuss         Correct / Improve     java   util   java.util   locale      intermediate        rare


 Q9. Name few classes that are part of java.util package ?
Ans. http://www.buggybread.com/2015/01/java-javautil-classes-and-interfaces.html

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

   Like         Discuss         Correct / Improve     java   java.util


 Q10. Name few Java util classes that were introduced with Java 7 ?
Ans. http://www.buggybread.com/2015/01/migrating-to-java-7-new-classes_25.html

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

   Like         Discuss         Correct / Improve     java   java.util   util   java 7   java7


 Q11. Name few Java Util classes introduced with Java 8 ?Core Java
Ans. http://www.buggybread.com/2015/01/migrating-to-java-8-new-classes_25.html

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

   Like         Discuss         Correct / Improve     java   java.util   util   java 8   java8


 Q12. What is the use of java.util.concurrent package in Java ?Core Java
 This question is still unanswered. Can you please provide an answer.


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

   Like         Discuss         Correct / Improve     java.util.concurrent


 Q13. What are the advantages and disadvantages of using lock classes from java.util.concurrent.locks vs. synchronized methods ?Core Java
Ans. http://www.devinline.com/2015/10/Lock-Vs-synchronized-in-java.html

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

   Like         Discuss         Correct / Improve     java.util.concurrent.locks  synchronization  synchronized methods


 Q14. Can we load environment variables into Properties in Java ? How ?Core Java
Ans. Yes

new Properties().putAll(System.getenv());

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

   Like         Discuss         Correct / Improve     java.util.properties  environment variables


 Q15. What is concurrent interface ?Core Java
Ans. ConcurrentMap is an interface and it is a member of the Java Collections Framework. It represents a Map that is capable of handling concurrent access to it without affecting the consistency of entries in a map. ConcurrentMap interface present in java.util.concurrent package.

HashMap operations are not synchronized, while Hashtable provides synchronization. Though Hashtable is thread-safe, it is not very efficient. To solve this issue, the Java Collections Framework introduced ConcurrentMap in Java 1.5.

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

   Like         Discuss         Correct / Improve     Concurrent Interface   java.util.concurrent   Java 8 Concurrency   java concurrency   java 8     Asked in 1 Companies



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: