Interview Question and Answers | Search Coding Interview Questions - javasearch.buggybread.com
Javasearch.buggybread.com

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.
Label / Company      Label / Company / Text

   



Interview Questions and Answers

   next 30
 Q201. What is a transitive dependency ? Can we override Transitive Dependency version and If Yes, how ?Maven
Ans. Transitive dependency is the dependencies not defined directly in the current POM but the POM of the dependent projects.

Yes we can override transitive dependency version by specifying the dependency in the current POM.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   maven dependencies   maven transitive dependency   technical lead   build management


Usually asked to experienced developers.
 Q202. What is a cyclic dependency ?Maven
Ans. A has dependency of B, B has dependency of C and C has dependency of A

With Maven 2 , came transitive dependency wherein in above scenario, C will acts as a dependency of A as if this dependency has been defined directly in A but the negative side is that if it leads to cyclic dependency , it creates problems.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   dependencies   cyclic dependencies   transitive dependencies   build management     Asked in 1 Companies        frequent


 Q203. 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


 Q204. What is the use of @GeneratedValue annotation in Hibernate?Hibernate
Ans. This annotation is added to the auto increment column with the strategy to increment the column value. Usually this is added to the surrogate primary key column and specified with the Database Sequence.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     hibernate   hibernate annotations   @generatedvalue   database sequence


 Q205. What is the use of runnable interface if we can always create a new thread using Thread class ?Core Java
Ans. It's a choice to be made whether to use first approach ( Thread class ) or second approach ( runnable interface ) by the programmer. The second facility has been given for cases where your class is already extending some parent class and hence cannot extend another class ( for Thread ) as Java doesn't allow multiple inheritance.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   threads   multithreading   runnable interface  concurrency


 Q206. What is a BlockingQueue?Data Structures
Ans. BlockingQueue is a Queue that supports operations that wait for the queue to become non-empty when retrieving and removing an element, and wait for space to become available in the queue when adding an element.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     blockingqueue   collections   java   concurrent collections     Asked in 10 Companies


 Q207. Which of the following collections stores its elements in insertion Order ?

a. HashMap
b. TreeMap
c. LinkedHashMap
d. LinkedMap
Core Java
Ans. LinkedHashMap

  Sample Code for LinkedHashMap

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     linkedhashmap   collections   java   map


 Q208. In what order the elements of a HashSet are retrieved ?

a. Random Order
b. Insertion Order
c. Natural Sorting Order
d. Inverse Natural Sorting Order
Core Java
Ans. Random Order

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     collections   set   hashset   java

Try 1 Question(s) Test


 Q209. Overridden methods must have the same ...

a. name
b. name and argument list
c. name, argument list, and return type
d. name, argument list, return type and belong to the same class
Ans. name and argument list

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   overriding

Try 2 Question(s) Test


 Q210. Which of the following is not the advantage of Mocking frameworks ?

a. It helps testing the module independently
b. It helps in faster unit testing
c. It helps in testing code even when external dependencies like service calls are not working
d. It helps in doing end to end Integration Testing
Ans. It helps in doing end to end Integration Testing

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     mocking frameworks   mockito   unit testing   junits


 Q211. Which of the following file is called deployment descriptor ?

a. application.xml
b. project.xml
c. web.xml
d. build.xml
Java EE
Ans. web.xml

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     configuration files   deployment   server   java


 Q212. Which of the following is dependency exclusion ?

a. A doesn't depend on C and then A marks C as excluded.
b. A Depends on B and B depends on C and then A can mark B as excluded.
c. A and B depends on C and then they can mark C as excluded.
d. A depends upon B and B depends upon C then A marks C as excluded.
Maven
Ans. A depends upon B and B depends upon C then A marks C as excluded.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven   dependency exclusion


 Q213. Which of the following is false about Constructors ?

a. Constructor can be overloaded
b. A no argument constructor is provided by the compiler if we declare only constructors with arguments.
c. Constructors shouldn't have any return types , not even void.
d. If super is not explicitly called, still super() is intrinsically added by the compiler.
Core Java
Ans. A no argument constructor is provided by the compiler if we declare only constructors with arguments.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   oops   constructor

Try 2 Question(s) Test


 Q214. Which of the following doesn't extend Collection interface ?

a. Set
b. List
c. Map
d. Queue
Core Java
Ans. Map

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   collections   collection interface


 Q215. Which of the following Java feature promotes Code Re usability ?

a. Abstraction
b. Encapsulation
c. Inheritance
d. Polymorphism
Core Java
Ans. Inheritance

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   java concepts   java features   code reusability


 Q216. Which of the following is not a build tool or plugin ?

a. Maven
b. Ant
c. Gradle
d. svn
Tool
Ans. svn

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   build tools


 Q217. enums are intrinsically ..

a. private
b. public
c. static
d. final
Core Java
Ans. static

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   enum


 Q218. What will happen if we don't have termination statement in recursion ?
Ans. Function call allocates a stackframe in stack. Every stackframe will use some memory to store local variables, parameters and to remember return address. Without terminating condition stackframes will keep consuming memory from stack and eventually program will result in stackoverflow error.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     recursion   break statement  break  stackoverflow exception  stackoverflow  memory management  memory  exceptions


 Q219. In which cases , moving methods to utility class could be useful ?Core Java
Ans. It could be worthy to move a method to util class if the method needs to be shared, doesn't require polymorphic behavior and need not be overridden in special cases.

Don't belong to one group through is-a relationship ( You can share through parent class method )

Don't implement a specific interface ( java 8 default methods )

Doesn't involve complex computing as you will be loosing the benefit of object state with just static method.

Doesn't require polymorphic behavior as static methods don't participate in runtime polymorphism.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     utility classes   util classes   static methods   application design        rare


This question can be asked in different variants like performace improvement of an application, improving performance for DB communication etc.
 Q220. What are the ways in which execution time of the code can be improved ?Solution
Ans. This depends on entirely upon the code type. For example

1.If its just logic, we can try it to short circuit or put the if / switch case with maximum probability in the beginning.

2. Can use faster data structures, for eg - random retrieval instead of sequence / iterator

3. Working with primitive types or even bytes instead of Objects, even though it may result in marginal improvement.

4. If its service call, then service call with bulk load can help

5. If DB Operation, then with use of Indices , Views or using ORM , cache etc.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     performance improvement  code optimization     Asked in 1 Companies


  Q221. Difference between GET and POST Requests ?Web Service
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


 Q222. How do you resolve Maven Dependencies issue while upgrading dependencies versions ?Maven
Ans. Step 1 - Upgrade the required dependency , perform build and check build errors

Step 2.1 - If the error is of missing transitive dependency ( which is rare and means that the previous version has a dependency which is missing in the later version ), I would look for the dependency in google and hence will include it as direct dependency in Pom file.

Step 2.2. If the error is for Duplicate dependencies , and the choice is between transitive and direct dependency, I usually remove the direct dependency.

Step 2.3 - If the error is for Duplicate dependencies , and both are transitive dependencies. I first make a choice ( usually later version ) and then ignore the previous version dependency.

Step 2.4 - If the error is for Duplicate dependencies , and there are more than 2 duplicates, I usually ignore it by specifying within maven-enforcer-plugin config.

Step 3 - Perform a Clean Build.

Step 4 - Check Maven Dependency Tree to make sure that Duplicates have been removed or dependency is there in case of missing dependency.

Step 5 - Perform tests and make sure that there are no runtime problems.

Step 6 - If there are runtime problems ( which very likely occurs if you have different version dependencies , very likely by doing 2.4 , you will have to remove step 2.4 and alternately perform 2.2 or 2.3 )

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     maven  maven dependency  transitive dependency


  Q223. What is coupling and Cohesion ?Design
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


Frequently asked Generic Question.
  Q224. Why do you want to work for our company ?General
Ans. [Open Ended Answer]

Usually answered stating your keen interest in the role offered and challenges and opportunities the role offers.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 42 Companies        frequent


 Q225. Design a Data Structure for a full text Search ?Design
 This question was recently asked at 'Myntra'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     Full Text Search  Data Structure     Asked in 1 Companies      expert


 Q226. Write a Program to reverse a Linked List ?Data Structure
 This question was recently asked at 'Myntra,Compro Technologies'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 2 Companies


 Q227. What are different types of variables a class can have ?Core Java
Ans. 1. Method local variables - These are declared and defined within a method ( instance or static methods ) and their scope is limited to the method itself. They are destructed once the execution of method completes. They are stored in stack memory.

2. Instance variables - These are declared as non static variables as part of the class.They are initialized as part of object creation ( constructor ) and are destructed by java's garbage collection mechanism and hence stored in heap.

3. Static variables - These are declared with the static keyword and are part of the class. They are initialized at the time of class loading and are destructed by java's garbage collection mechanism and hence stored in heap.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java variables


  Q228. Why java doesn't support multiple Inheritance ?

or

Explain Java Diamond Problem.
Core Java
Ans. class A {
void test() {
System.out.println("test() method");
}
}

class B {
void test() {
System.out.println("test() method");
}
}

Suppose if Java allows multiple inheritance like this,

class C extends A, B {
}

A and B test() methods are inheriting to C class.

So which test() method C class will take? As A & B class test() methods are different , So here we would Facing Ambiguity.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     multiple inheritance  object oriented programming (oops)  oops concepts  diamond problem     Asked in 20 Companies      basic        frequent


 Q229. Design an app to find 10 most visited urlsCore Java
 This question was recently asked at 'Wayfair'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q230. Trim a string without using String library methodCore Java
 This question was recently asked at 'Ariba'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     code  coding.string  trim a string     Asked in 1 Companies


previous 30   next 30

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: