Interview Questions and Answers for 'Ato' | Search Interview Question - 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 - Order By Rating

   
Very frequently asked. Favorite question in Walk in Drive of many Indian service companies.
  Q61. What is the difference between ArrayList and LinkedList ?Core Java
Ans. Underlying data structure for ArrayList is Array whereas LinkedList is the linked list and hence have following differences -

1. ArrayList needs continuous memory locations and hence need to be moved to a bigger space if new elements are to be added to a filled array which is not required for LinkedList.

2. Removal and Insertion at specific place in ArrayList requires moving all elements and hence leads to O(n) insertions and removal whereas its constant O(1) for LinkedList.

3. Random access using index in ArrayList is faster than LinkedList which requires traversing the complete list through references.

4. Though Linear Search takes Similar Time for both, Binary Search using LinkedList requires creating new Model called Binary Search Tree which is slower but offers constant time insertion and deletion.

5. For a set of integers you want to sort using quicksort, it's probably faster to use an array; for a set of large structures you want to sort using selection sort, a linked list will be faster.

  Sample Code for ArrayList

  Sample Code for LinkedList

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

   Like         Discuss         Correct / Improve     collections   java   data structures   arraylist   linkedlist   arraylist vs linkedlist     Asked in 61 Companies      Basic        frequent

Try 1 Question(s) Test


Frequently asked question in companies using Hibernate.
  Q62. What is Lazy Initialization in Hibernate ?Hibernate
Ans. It's a feature to lazily initialize dependencies , relationship and associations from the Database. Any related references marked as @OneToMany or @ManyToMany are loaded lazily i.e when they are accessed and not when the parent is loaded.

  Sample Code for Lazy Initialization

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

   Like         Discuss         Correct / Improve     hibernate   lazy loading hibernate   lazy initialization hibernate   architecture     Asked in 77 Companies      Basic        frequent

Try 2 Question(s) Test


 Q63. What are few iterator classes provided by Java ?
Ans. http://www.buggybread.com/2015/01/java-iterator-classes-and-interfaces.html

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

   Like         Discuss         Correct / Improve     java   collections   iterator


Very Frequently asked. Have been asked in HCL Technologies very frequently ( based on 3 feedback ). Among first few questions in many interviews.
  Q64. Differences between abstract class and interface ?Core Java
Ans. Abstract classes can have both abstract methods ( method declarations ) as well as concrete methods ( inherited to the derived classes ) whereas Interfaces can only have abstract methods ( method declarations ).

A class can extend single abstract class whereas it can implement multiple interfaces.

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

   Like         Discuss         Correct / Improve     java   classes   abstract class   interfaces   abstract class vs interface   abstract classes vs interfaces     Asked in 82 Companies      basic        frequent


 Q65. In which cases isn't instanceof operator a bad practice?Core Java
Ans. To avoid ClassCastException.

Though the following code will compile fine but will result in ClassCastException during runtime.

Fruit fruit = new Apple();
Banana banana = Banana(fruit); // ClassCastException


This code will not give compile time error as Banana and Fruit are related as Banana either extends or implement Fruit, So downcasting is acceptable. With this code we assume that the Fruit handler will have the Apple object at that point, violating which the code will throw the exception.

This exception can be avoided by following code.

Fruit fruit = new Apple();
if(fruit instanceOf Banana){
Banana banana = Banana(fruit); // ClassCastException
}

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

   Like         Discuss         Correct / Improve     java   instanceof   classcastexception   runtime exceptions  instanceOf operator

Try 2 Question(s) Test


 Q66. Difference between prefix and postfix increment operator ?
Ans. Prefix operator performs the increment and then assignment whereas its inverse for postfix operator.

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

   Like         Discuss         Correct / Improve     prefix increment operator   postfix increment operator   operators   java      basic        frequent


 Q67. Write code to check if an integer is odd or even using ternary operator
Ans. http://javasearch.buggybread.com/CodeSnippets/searchCodeSamples.php?&category=code&searchOption&keyword=963

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

   Like         Discuss         Correct / Improve     ternary operator  code  coding


 Q68. Is Iterator a class ?
Ans. No, iterator is an interface that is used to parse through the elements of a Collection

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

   Like         Discuss         Correct / Improve     collections  iterator


 Q69. What is Associativity while evaluating a Java statement ?Core Java
Ans. Associativity determines whether an expression is evaluated left-right or right-left. When an expression has two operators with the same precedence, the expression is evaluated according to its associativity.

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

   Like         Discuss         Correct / Improve     associativity  expression evaluation  operator


 Q70. Which of the following is true for == operator ?Core Java
a. For primitives, == checks if the variables on left and right have same data type
b. For primitives, == checks if the variables on left and right have same value
c. For Objects, == checks if the references on left and right have same data type
d. For Objects, == checks if the references on left and right have same value

Ans.b. For primitives, == checks if the variables on left and right have same value

 Q71. Which of the following is equivalent to following logic ?

Not X && Not Y
Core Java
a. x || Y
b. Not(X || Y)
c. Not(X && Y)
d. Not X && Y

Ans.b. Not(X || Y)

previous 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: