Interview Questions and Answers - Order By Rating Not frequently asked as it was introduced with Java 8. Ans. StringJoiner is a util method to construct a string with desired delimiter. This has been introduced with wef from Java 8.
Sample Code
StringJoiner strJoiner = new StringJoiner ( "." );
strJoiner . add ( "Buggy" ). add ( "Bread" );
System . out . println ( strJoiner ); // prints Buggy.Bread
Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java8   java 8   string   stringjoinerNot frequently asked as it was introduced with Java 8. Q1452. What is the use of Optional ? Core Java
Ans. Optional is a good way to protect application from runtime nullPointerException in case the the absent value has been represented as null. So basically Optional class provides the type checking during compile time and hence will never result in NPE. For ex - List> intList = new ArrayList>(); intList.add(Optional.empty()); intList.add(Optional.of(new Employee("abc"))); intList.add(Optional.of(new Employee("xyz"))); intList.add(Optional.of(new Employee("123"))); System.out.println(intList.get(0).getName()); So Now , even when the first list element is empty, this code will never throw an NullPointerException. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java8   java 8   optional Q1453. Have you ever used StringTokenizer ? Core Java
Ans. No, Alternatively I have used String.split("\\s") for achieving the same function. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   string   stringtokenizer Q1454. What is ConcurrentLinkedDeque ? Core Java
Ans. It's a Collections concrete class that provides implementation of a Double Ended queue that allows concurrent insertion, removal, and access operations that can be executed safely across multiple threads. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   queue   deque   concurrent collections Q1455. What is CopyOnWriteArrayList ?
Ans. Its a type of ArrayList in which all Write operations , i.e add and set are performed by creating a new copy. This array never changes during the lifetime of the iterator, so it never throws ConcurrentModificationException Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   list   arraylist   copyonwritearraylist   ConcurrentModificationException Asked in 1 Companies Q1456. What are the advantages and disadvantages of CopyOnWriteArrayList ? Core Java
Ans. This collections class has been implemented in such a manner that it can never throw ConcurrentModificationException. As it performs update and write operations by creating a new copy of ArrayList, It's slower compared to ArrayList. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   list   arraylist   copyonwritearraylist   advantages-disadvantages   ConcurrentModificationException Asked in 4 Companies Expert Q1457. Name few Concurrent Collection Classes ?
Ans. ConcurrentHashMap ConcurrentLinkedDeque ConcurrentLinkedQueue ConcurrentMap ConcurrentNavigableMap ConcurrentSkipListMap ConcurrentSkipListSet Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   concurrent collections Q1458. Name few Collections Map implementations ?
Ans. AbstractMap ConcurrentHashMap ConcurrentSkipListMap EnumMap HashMap IdentityHashMap LinkedHashMap SystemFlavorMap TreeMap WeakHashMap Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   map Q1459. What is ConcurrentModificationException ? Core Java
Ans. This is the exception that is thrown when we try to modify the non concurrent collection class while iterating through it. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   concurrentmodificationexception   exception  concurrency Asked in 14 Companies intermediate Q1460. What is ArrayIndexOutOfBoundException ? Core Java
Ans. Exception thrown by the application is we try to access an element using an index which is not within the range of array i.e lower than 0 or greater than the size of the array. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   exceptions   arrayindexoutofboundexception Asked in 1 Companies Q1461. how can we generate JavaDoc documentation for our code ? Eclipse
Ans. In Eclipse, Go to File -> Export -> Java -> JavaDoc Select the projects , other properties and output directory for which JavaDoc and Click Finish. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   javadoc   eclipse Q1462. Can we generate Java Documentation using Export -> JavaDoc using a jar file ? Eclipse
Ans. Yes, If the jar contains the source code. No, If it contains only classes. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   javadoc   eclipse Q1463. Can we initialize member variables within static block ?
Ans. Static block is like static method that gets executed upon class loading. The way static method allows accessing member variables ( using object references only ), the same static block can also access and initialize member variables. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   static block Q1464. Difference between jar , war and ear ? Java EE
Ans. Jar is Java Archieve i.e compressed Class or Class / Java files.
War comprises of compressed Servlet class files,JSP FIles,supporting files, GIF and HTML files.
Ear comprise of compressed Java and web module files ( was files ). Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   j2ee   jar   web development   war   ear   build management   release management Asked in 12 Companies basic   frequent Q1465. Name few interfaces that extends Collection Interface ?
Ans. http://www.buggybread.com/2015/02/java-collections-interfaces-that.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   collection interface Q1466. Name few classes that extends Number Class ?
Ans. http://www.buggybread.com/2015/02/java-util-classes-that-inherit-number.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   data types   number class Q1467. Name few classes that extend Thread class ? Core Java
Ans. http://www.buggybread.com/2015/02/java-threads-classes-that-inherit.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   threads   multithreading   thread class Asked in 1 Companies Q1468. Name few classes that extends Collections class ?
Ans. http://www.buggybread.com/2015/02/java-collections-classes-that-inherit.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   collections class Q1469. 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 Q1470. 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 Q1471. Name few abstract classes of Java collections framework ?
Ans. http://www.buggybread.com/2015/02/java-collections-abstract-classes.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections Q1472. Name few classes that implement Cloneable interface ?
Ans. http://www.buggybread.com/2015/02/java-collections-classes-that-implement_58.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   cloneable  cloning Q1473. Name few classes that implement Set interface ?
Ans. http://www.buggybread.com/2015/02/java-collections-classes-that-implement_78.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   set Q1474. Name few classes that implement iterable interface ?
Ans. http://www.buggybread.com/2015/02/java-collections-classes-that-implement_45.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   iterable Q1475. Name few classes that implement Map interface ?
Ans. http://www.buggybread.com/2015/02/java-collections-classes-that-implement_82.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   map Q1476. Name few classes that implement List interface ?
Ans. http://www.buggybread.com/2015/02/java-collections-classes-that-implement_35.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   list Q1477. Name few classes that implement Queue interface ?
Ans. http://www.buggybread.com/2015/02/java-collections-classes-that-implement_1.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections.queue Q1478. Name few classes that implement Collection interface ?
Ans. http://www.buggybread.com/2015/02/java-collections-classes-that-implement.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   collection interface Q1479. Name few classes java provides for File compression ?
Ans. http://www.buggybread.com/2015/01/java-zip-classes-and-interfaces.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   zip Q1480. Name few Buffered IO classes and interfaces ?
Ans. http://www.buggybread.com/2015/01/java-io-buffered-classes-and-interfaces.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   io   input output   buffered io   buffered input output