Interview Questions and Answers - Order By Newest Q631. Why is a constant defined as a static final in Java? Core Java
Ans. Final makes sure that the value doesn't change after initialization and static makes sure that there is only one copy that can be shared across objects. Making it non static will unnecessarily create a different copy per object wherein the same value will kept for all copies ( as its final and cannot be changed ). Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   static   final variables   variable constants basic   frequent Q632. What is the difference between public class and class ? Core Java
Ans. Class without any access specifier has the default scope i.e it can be accessed by any class within same package. Class declared public can be accessed from anywhere. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   access specifier   access modifiers   public class   class Try 1 Question(s) Test Q633. Will this code compile ? public class BuggyBread1{ abstract public void test(); } Core Java
Ans. No. It will give the compilation error saying "The abstract method test in type BuggyBread1 can only be defined by an abstract class". We need to declare the class abstract for it to have any abstract method. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   abstract class   abstract methods   java compilation error Q634. Will this Code compile ? abstract public class BuggyBread1{ abstract public void test(){}; } Core Java
Ans. No. This will give a compilation error saying "Abstract methods do not specify a body". Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   abstract classes   abstract methods   java compilation error   java coding   java code   coding   yes-no Q635. Give an Example for Builder Pattern ? Core Java
Ans. String str = new StringBuilder().append("Buggy").append("Bread").toString(); Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   builder pattern   design pattern   stringbuilder   string Asked in 3 Companies Try 1 Question(s) Test Q636. Is this Polymorphism ?
Map<String, List<String>> inventoryManagerCountMap = new HashMap<String, ArrayList<String>>(); Core Java
Ans. No. This will result in compilation error as Polymorphism cannot be performed on Object types. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   polymorphism  object oriented programming (oops)  oops conceptsRarely asked as it was introduced with Java 8. Q637. Difference between DoubleSummaryStatistics , IntSummaryStatistics and LongSummaryStatistics ? Core Java
Ans. They all does the same task i.e to compute statistical information on the stream of data. They differ by the way they store the statistical information as they expect a different data type of the values being used. IntSummaryStatistics and LongSummaryStatistics expect non floating point values and hence stores the statistical information like min,max and sum as non floating values ( int or long ) whereas DoubleSummaryStatistics stores these information as floating value. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java8   java 8   lambda expressions   doublesummarystatistics   intsummarystatistics   longsummarystatistics   summarystatistics Q638. 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 Q639. 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 Q640. 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 Q641. 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 Q642. 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 Q643. 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 Q644. 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 Q645. 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 Q646. 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 Q647. 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 Q648. 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 Q649. 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 Q650. 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 Q651. 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 Q652. 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 Q653. 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 Q654. 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 Q655. 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 Q656. 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 Q657. 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 Q658. 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 Q659. 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 Q660. 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