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. |
|
| ||||
Interview Questions and Answers - Order By Rating | ||||
| ||||
Ans. Maven Module has a Parent whereas Project doesnt. when we add the parent section to the pom file, it adds the module section to the parent project pom file. When we execute mvn compile / install, it basically checks that module section of the parent to identify all the modules that needs to be compiled first. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  maven project vs module  maven project  maven module   frequent | ||||
| ||||
Ans. 1. HashSet doesnt maintain its elements in any specific order and is all random whereas TreeSet maintains elements in natural order 9 order defined by the equals method of TreeSet element type ) 2. TreeSet doesnt allow null elements whereas HashMap does. 3. As TreeSet orders elements and is hence insertion is comparatively slower. 4. HashSet performs basic operations like add(), remove(), contains(), size() etc. in a constant size time. A TreeSet performs these operations at the order of log(n) time. 5. HashMap in Java internally backs a HashSet. A NavigableMap backs a TreeSet internally. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  collections  hashset  treeset  set   hashet vs treeset Asked in 4 Companies Basic   frequent | ||||
Try 1 Question(s) Test | ||||
| ||||
Ans. System is a class within java.lang package that contains several useful class fields and methods. It cannot be instantiated and hence can use only statically.even in this case this has been used statically i.e with class name itself and without creating an instance. out is the static reference of Printstream declared as following in the System Class - public final static PrintStream out = null; println is the method of PrintStream class. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  System class  Streams  Input Output  println Asked in 1 Companies basic   frequent | ||||
| ||||
Ans. I use trace for debugging purpose. Info for displaying some important info, thought its rare as we have enabled info logging in production. Warn in case something went wrong but we still resume the flow in spite of it or have take alternate flow as its expected sometimes. Error logging in case it was completely unexpected and mostly when it breaks the flow. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve     frequent | ||||
| ||||
Ans. Because the way float values are stored its not precise. For example - 0.1 is actually stored as 0.1000000000000000055511151231257827021181583404541015625 | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  double  float  data type basic   frequent | ||||
| ||||
Ans. Coupling is the degree of interdependence between software modules, a measure of how closely connected two modules are or the strength of the relationships between modules. Cohesion refers to the degree to which the elements of a module belong together. Cohesion measures the strength of relationship between pieces of functionality within a given module. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  coupling  cohesion Asked in 10 Companies   frequent | ||||
Basic and Very Frequently asked. | ||||
| ||||
Ans. Polymorphism means the condition of occurring in several different forms. Polymorphism in Java is achieved in two manners 1. Static polymorphism is the polymorphic resolution identified at compile time and is achieved through function overloading whereas 2. Dynamic polymorphism is the polymorphic resolution identified at runtime and is achieved through method overriding. | ||||
Sample Code for overloading Sample Code for overriding | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  polymorphism  object oriented programming (oops)  oops concepts  oops concepts Asked in 108 Companies Basic   frequent | ||||
Try 2 Question(s) Test | ||||
Very frequently asked. | ||||
| ||||
Ans. Synchronize is used to achieve mutual exclusion i.e at one time, the segment of the code, method that has been declared synchronized should be executed by single thread only and hence the lock needs to be retrieved before executing the segment and then released. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  threads  multithreading  synchronized Asked in 5 Companies basic   frequent | ||||
Frequently asked. | ||||
| ||||
Ans. A finally block of code always executes, whether or not an exception has occurred.The only time finally won't be called is if you call System.exit() or if the JVM crashes first. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  finally  exception handling  exceptions Asked in 4 Companies basic   frequent | ||||
| ||||
Ans. An Internet Protocol address is a numerical label assigned to each device participating in a computer network. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  ip address Asked in 2 Companies basic   frequent | ||||
Very Frequently asked to fresh graduates and less experienced. | ||||
| ||||
Ans. Abstraction Polymorphism Inheritance Encapsulation | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  oops  oops concepts Asked in 1 Companies basic   frequent | ||||
| ||||
Ans. A trigger is a special kind of stored procedure that automatically gets executed upon an event in the database server. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  database   trigger Asked in 10 Companies basic   frequent | ||||
| ||||
Ans. Stored procedures are a batch of SQL statements along with programming constructs ( if else, loops etc ) and stored as a single program that can be called by different clients and hence reused. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  database  stored procedure Asked in 2 Companies basic   frequent | ||||
| ||||
Ans. TreeSet and TreeMap are used for maintaining sorted elements. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  ordered collections  sorted collections Asked in 1 Companies basic   frequent | ||||
Frequently asked to Fresh graduates. | ||||
| ||||
Ans. http://algs4.cs.princeton.edu/11model/BinarySearch.java.html | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  binary search  search Asked in 5 Companies basic   frequent | ||||
Try 1 Question(s) Test | ||||
| ||||
Ans. http://www.programcreek.com/2012/11/quicksort-array-in-java/ | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  quick sort  sort Asked in 2 Companies   frequent | ||||
| ||||
Ans. Distributed file system and Map Reduce system. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hadoop  bigdata  hadoop system components   frequent | ||||
| ||||
Ans. Multiple Inheritance refers to the concept of a class inheriting multiple classes. Example - Class C extends Class A ,Class B. This is not allowed in Java. Multilevel Inheritance refers to the concept of Inheritance in a chain. Example - Class B extends Class A, Class C extends Class B. This is permitted in Java. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  inheritance  object oriented programming (oops)  oops concepts   multiple inheritance  object oriented programming (oops)  oops concepts   multi level inheritance  object oriented programming (oops)  oops concepts Basic   frequent | ||||
| ||||
Ans. No, If both Parent and Derived are outer classes. public class Vehicle { private static String manufacturingDate = "2016"; } public class Car extends Vehicle{ public static void main(String args[]){ System.out.println(manufacturingDate); // error - The field Vehicle.manufacturingDate is not visible } } Yes, If derived is the inner class of Parent. public class Vehicle { private static String manufacturingDate = "2016"; static public class Car extends Vehicle{ public static void main(String args[]){ System.out.println(manufacturingDate); // no problem } } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  private members   private methods   private variables   inheritance  object oriented programming (oops)  oops concepts   members visibility   inner classes  nexted classes basic   frequent | ||||
| ||||
Ans. GET is supposed to get information from the server. Client sends the minimal information so that Server can respond with the response body on basis of request. For example - You want to get complete employment record for employee id 123 POST is supposed to send the information for submission. Payload or a Body is usually sent so that it can be persisted on the server. For example - Sending the complete information of an employee ( id, name , dept etc ) to the server for persisting it. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  get vs post   web service   rest Asked in 11 Companies basic   frequent | ||||
| ||||
Ans. 1. As Request Param 2. As Path Param 3. Part of Payload / Body in case of PUT and POST Request | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  web service   rest basic   frequent | ||||
| ||||
Ans. It depends on whether the request object is persisted as it is or its first dismantled, modified or refactored and then inserted into DB. In first case, it should be a PUT request whereas in second case it should be a POST Request. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Put vs Post   Rest Asked in 2 Companies intermediate   frequent | ||||
Frequently asked question in companies using Rest Web services. | ||||
| ||||
Ans. PUT requests are only meant to place the object as it is on server. For example - You want a file to be uploaded and then placed in a particular folder or you want an Employee object to be persisted in the table. POST requests are also meant to transfer information from client to server but that information once received at the server is evaluated , modified or refactored before persisting. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Put vs Post   Rest Asked in 5 Companies   frequent | ||||
| ||||
Ans. It is a class level variable that is shared among the objects of that class. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  static   static variables   class level variables Asked in 1 Companies basic   frequent | ||||
Try 1 Question(s) Test | ||||
Frequently asked for Lead and Architect positions. Recently asked in many US companies. | ||||
| ||||
Ans. Anti-pattern is simply the creation of a pattern in your coding that negatively affects your code i.e the Negatives surpasses the positives. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  anti patterns  design patterns Asked in 9 Companies   frequent | ||||
| ||||
Ans. When a Table Join itself , it's a Self Join. For example - we like to know the pair of department names where first dept has lesser employees than the later. Select D1.name , D2.name from Dept D1, Dept D2 where D1.employee_count < D2.employee_count | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  sql  joins  self join  self-join  Pair of employee names with first having lesser salary than later  Pair of department names where first dept has lesser employees than the later Asked in 26 Companies basic   frequent | ||||
| ||||
Ans. DAO is Data Access Object which is used within Persistence Layer to make Database Transaction. For example , the class holding the Database connection and CRUD methods. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  DAO  Data Access Object basic   frequent | ||||
| ||||
Ans. DTO is Data Transfer Object i.e Pojo which is supposed to move between different layers of software architecture for transferring information. Example could be the object passed from client in case of web service call or the object passed to Persister for Database Persistence. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  DTO   Data Transfer Object basic   frequent | ||||
| ||||
Ans. CRUD stands for "Create, read, update and delete" are the basic functions of persistence. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  CRUD  Persistence  Database  Database Operations Asked in 3 Companies Basic   frequent | ||||
All these acronyms JDK,JRE,JVM etc are very frequently asked. | ||||
| ||||
Ans. JRE or Java Runtime Environment is the Java Virtual Machine on which class files are executed. It includes borwser plugins that facilitates execution of class files in browsers. JDK or Java Development Kit includes JRE , compiler and development tools. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  JDK  JRE  JDK vs JRE  Difference between Asked in 4 Companies basic   frequent | ||||