Interview Questions and Answers - Order By Newest Q1001. 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 Q1002. 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 Q1003. 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 Q1004. 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 Q1005. 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 Q1006. Can we have multiple classes in single file ?
Ans. Yes, but there can be only 1 public class in a single file. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   classes Q1007. 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 Q1008. 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 Q1009. 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 Q1010. 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 Q1011. 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 Q1012. 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 Q1013. 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 Q1014. 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 Q1015. 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 Q1016. 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 Q1017. 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 Q1018. Which is of the following is NOT TRUE for JVM ? a. JVM reads Byte Code and generates Machine Code. b. JVM is a virtual Machine that acts as a intermediary between Java Application and Host Operating System. c. JVM reads Source Code and generates Byte Code. d. JVM acts as a translator that translates different Machine code ( on the basis of Host Machine ) for a common Byte Code.
Ans. JVM reads Source Code and generates Byte Code. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   jvm Q1019. If we add Enum constants to a sorted collection ( Treemap , TreeSet ), What will be the order in which they will be maintained ? a. Sorted Collection wont maintain them in any order. b. Insertion Order c. Order in which constants are declared. d. Natural Sorting Order.
Ans. Order in which constants are declared. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  enum   collections   sorted collections   treemap   treeset   compareto   comparable   java Q1020. Which of the following is not type of inner classes ? a. Simple Inner Class b. Static Nested Inner Class c. Method Nested Static Inner Class d. Anonymous Inner Class
Ans. Method Nested Static Inner Class Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   classes   inner classes Try 1 Question(s) Test Q1021. Which of the following was not introduced with Java 5 ? a. Generics b. Strings within Switch c. Enums d. Annotations
Ans. Strings within Switch Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java5 Q1022. Which interface does java.util.Hashtable implement ? a. List b. Set c. Collection d. Map Core Java
Ans. Map Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hashtable   java   collections Q1023. Which of the following is false ? a. HashMap came before HashTable. b. HashMap allows null values whereas Hashtable doesn’t allow null values. c. HashTable and HashMap allow Key-Value pairs. d. Hashtable is synchronized whereas HashMap is not.
Ans. HashMap came before HashTable. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  map   hashmap   hashtable   collection   java Try 2 Question(s) Test Q1024. Which of the following is true ? a. We can serialize static variables b. We can serialize transient variables c. We can serialize final variables d. We can serialize instance methods
Ans. We can serialize final variables Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  serialization   java   file io Try 1 Question(s) Test Q1025. Which of the following is not the use of this keyword ? a. Passing itself to another method b. To call the static method c. Referring to the instance variable when local variable has the same name d. Calling another constructor in constructor chaining
Ans. To call the static method Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  this   this keyword   java Q1026. Which of the collections allows null as the key ?
a. HashTable
b. HashMap
c. TreeMap
d. LinkedHashMap Core Java
Ans. HashMap Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   map  hashtable Asked in 2 Companies basic   frequent Q1027. What is the initial state of a thread when it is created and started ? a. Wait b. Running c. Ready d. Sleep
Ans. Ready Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   threads   multithreading   thread states Q1028. What state does a thread enter when it terminates its processing? a. Wait b. Ready c. Dead d. Running
Ans. Dead Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   threads   multithreading   thread states Q1029. How many bits are used to represent Unicode ? a. 8 bits b. 16 bits c. 24 bits d. 32 bits
Ans. 16 bits Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   character coding   character encoding Q1030. How do I determine which POM contains missing transitive dependency? a. mvn -A b. mvn -M c. mvn -R d. mvn -X Maven
Ans. mvn -X Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  maven   maven transitive dependencies