Interview Questions and Answers - Order By Newest Rarely asked as it was introduced with Java 8. Ans. DocLint Provide a means to detect errors in Javadoc comments early in the development cycle and in a way that is easily linked back to the source code. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java 8   doclint   java8 featuresRarely asked as it was introduced with Java 8. Q902. What are the errors identified by DocLint ? Core Java
Ans. Bad syntax, such as unescaped characters or unmatched parentheses Bad HTML, such as invalid or missing tags or attributes Bad references, such as referencing a non-existent type with @see Accessibility errors, such as a missing summary or caption from a table Missing info, such as an undocumented parameter Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java8   java 8   doclint Q903. What is the difference between out.println(a+b); and out.println (a+" " +b); in Java? with a=2 and b=1 Core Java
Ans. First will give the ouput as 3 and the second will give output as 2 1 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   system.out.println   coding Q904. Which sorting algorithm is used by Collections.sort() in Java ? Core Java
Ans. The sorting algorithm is a modified mergesort. This algorithm offers guaranteed n log(n) performance. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   algorithm   collections   collections.sort   sorting algorithm expert Try 1 Question(s) Test Q905. What doesn Http keep alive header does ? Java EE
Ans. Http is connection less by default. header informs hosts to keep the connection alive so that the same connection can be reused for multiple communication. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   http   http-alive   client server communication Q906. What is the difference between Data Type and Data Structure ? Core Java
Ans. Data type: a set of values together with operations on that type Data structure: a physical implementation of a data type Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   data structure   data type Q907. Is it correct to say that Interfaces are abstract data types ?
Ans. No. Data Type holds data whereas Interface doesn't hold anything. Interface is a contract about how to communicate with the underlying Class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   interface   data type Q908. Do you see Class as a Data Type or Data Structure ?
Ans. Class can be better seen as Data Type. This could be implemented as a Data Structure too in some cases. One thing worth understanding here is that Data type and Data structure are conceptual things. Class could be implementation of either of these. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   class   data type   data structure Q909. How many elements will be there in TreeSet after the last line and Why ? TreeSet set = new TreeSet(); set .add(new String("abc")); set .add(new String("abc")); Core Java
Ans. One. As we haven't specified the type of TreeSet, it being evaluated with the first element insertion. Once it's identified that it's of type String and as no comparator has been defined, the comparison is done using the String compareTo method. String compareTo method compares the elements by the content / value. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   set   treeset   string   compareto   coding   code Q910. Which of the following data type you will prefer to store price - BigDecimal or Double ?
Ans. BigDecimal if memory and Performance is not critical concern, otherwise double. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   data types   double   bigdecimal Q911. Which takes more memory - float or Float ? Core Java
Ans. float is a native data type whereas Float is a class. A Float object will always take more memory than float variable as there are metadata overheads with the objects. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   data type   float Asked in 3 Companies basic   frequent Q912. Difference between HashMap and WeakHashMap ?
Ans. WeakHashMap uses weak reference for keys, which means if the key object doesn't have any reference then both key/value mapping will become eligible for garbage collection. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   hashmap   weakhashmap   difference between   garbage collection   ebay Q913. Which tree is used to implement TreeMap in Java?
Ans. Red Black Tree Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   treemap   map expert Q914. What is collision in hash collections ? Core Java
Ans. Collision is the situation when two different elements have the same Hash Code. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   collision   hashcode  hash code   hash collections   ebay Asked in 1 Companies intermediate   frequent Q915. When are static and instance methods resolved ? During compile time or Runtime ?
Ans. Static methods are resolved during compile time and hence they cannot participate in runtime polymorphism. Instance methods are resolved during runtime. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   static methods   methods   runtime polymorphism intermediate Q916. What will the following code result ? List> intList = new ArrayList>(); intList.add(Optional.empty()); intList.add(Optional.of(2)); intList.add(Optional.of(3)); intList.add(Optional.of(4)); System.out.println(intList.get(null));
Ans. Compile time error at last line as the get method expect argument of type native int. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  arraylist   list   coding   collections Q917. What will the following code result ? Will it compile ? List> intList = new ArrayList>(); intList.add(Optional.empty()); intList.add(Optional.of(2)); intList.add(Optional.of(3)); intList.add(Optional.of(4)); System.out.println(intList.get((Integer)null));
Ans. Yes but the last line will throw NullPointerException upon execution. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  collections   arraylist   list   coding Q918. What will be the output ?Integer a = 10, b =10;Integer c = 10, d = 1000;System.out.println(a == b);System.out.println(c ==d); Core Java
Ans. truefalse Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   coding   equality   object equality Q919. How to determine if the linked list has a cycle in it ?
Ans. http://stackoverflow.com/questions/494830/how-to-determine-if-a-linked-list-has-a-cycle-using-only-two-memory-locations Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  linked list   data structure   algorithm   java   ebay Q920. What is OutOfMemoryError in Java? Core Java
Ans. OutOfMemoryError in Java is a subclass of VirtualMachineError and is thrown by JVM when it runs out of heap memory. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  outofmemoryerror   error   exceptions   jvm   java   heap memory   heap Q921. What is Apache Kafka ? BigData
Ans. Kafka is a distributed, partitioned, replicated commit log service. It provides the functionality of a messaging system through messages being written to logs. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  kafka   bigdata   message queue Asked in 4 Companies Q922. What is a broker in Apache Kafka ?
Ans. Kafka is run as a cluster comprised of one or more servers each of which is called a broker Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  kafka   bigdata   message queue Q923. What is a Topic in Apache Kafka ?
Ans. A topic is a category or feed name to which messages are published Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  kafka   bigdata   message queue Q924. Do you know of any facility to convert between Scala and Java Util Collections ? Scala
Ans. We can use JavaConversions which is a part of Scala Library. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  scala   scala collections   java collections Q925. Have you used Kafka in your project ? If Yes, for what ?
Ans. We were using Kafka as a replacement for JMS Message Queue for better throughput. We were just using a simple Java multi threaded client as order of message consumption didn't matter to us. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  kafka   bigdata   message queue   java Q926. Does Kafka uses ZooKeeper ?
Ans. Yes Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  kafka   bigdata   yes-no   yes no Q927. Which interfaces are implemented by BatchUpdateException?
Ans. [Iterable] Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   BatchUpdateException   include Q928. What is the package name for CertStoreParameters class?
Ans. java.lang Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  interfaces   java   CertStoreParameters   include Q929. Which is the Parent Class of CertStoreParameters class?
Ans. Clonable Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  interfaces   java   CertStoreParameters   include Q930. Action Class is singleton and hence not thread safe in .. a. All versions of Struts b. Struts 1 c. Struts 2 d. None of Struts versions
Ans. Struts 1 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  struts   j2ee   mvc frameworks   struts1   struts2