Interview Questions and Answers - Order By Rating      Ans. Mutator is another name for setter methods, i.e the method allows for mutating the property of an object and eventually the state of the object.   Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve        setter method  mutator  Q482. What are the core interfaces in Hibernate?  Hibernate 
Ans. Session,SessionFactory,Configuration,Transaction,query and Criteria   Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve        core interfaces of Hibernate      Asked in 1 Companies          frequent  Try 1 Question(s) Test  Q483. Where the prepared Statement object creating - In Java application or DB ?  Database 
Ans. Prepared Statement objects are created and cached at database level.   Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve        Prepared statements      Asked in 1 Companies  Try 1 Question(s) Test  Q484. What are the benefits of using prepared statements ? Does that benefit extend only if similar prepared statements are used within a application or it extends even with multiple applications having similar prepared statement ?  Database 
Ans. Prepared Statements helps in reuse of database execution plan which can be cached at Database level and hence helps achieving faster execution and performance. As cached ps objects are creating at Database level and not application level, the use and benefit extends across multiple applications.   Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve        Prepared statements  benefits of prepared statements      Asked in 1 Companies  Try 1 Question(s) Test  Q485. What are the benefits of using Prepared statements ?  Database 
Ans. 1. Precompilation , DB-side caching and reuse of same execution plan leads to overall faster execution. 
 
2. Automatic prevention of SQL injection attacks by escaping special characters   Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve        Prepared statements  benefits of prepared statements      Asked in 1 Companies  Try 1 Question(s) Test  Q486. What is the use of Hibernate session.evict()?  Hibernate 
Ans. It is used to dissociate / disconnect a particular object from the session.   Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve        hibernate session evict  hibernate evict  Q487. What is the use of Hibernate session.clear() ?  Hibernate 
Ans. It is used to clear the session and is used to dissociate disconnect all the objects from the session.   Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve        hibernate session clear  Q488. What is the difference between session.clear and session.evict ?  Hibernate 
Ans. session.clear clears all the objects from session whereas session.evict is used for evicting a particular entity.   Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve        hibernate session clear  hibernate evict Try 2 Question(s) Test  Q489. How can we make sure that Hibernate doesn't update the entity changes to DB or how to keep the entity detached ?  Hibernate 
Ans. If it's only a read only transaction, we can wrap the get / load call in read only transaction. 
 
If we want it to be application wide, we an set the flush mode accordingly or else we can evict the entity object to remove them from session.   Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve         Try 2 Question(s) Test  Q490. Does Hibernate synchronize entity with the database automatically i.e any change to entity gets updated in DB ?  Hibernate 
Ans. Yes, the feature is there but can be override with changing the Flush Mode.   Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve        Ans. Priority inversion is a problematic scenario in scheduling in which a high priority task is indirectly preempted by a lower priority task effectively inverting the relative priorities of the two tasks.   Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve              Asked in 5 Companies   Q492. What is priority inversion inheritance method?  
Ans. https://en.wikipedia.org/wiki/Priority_inversion    Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve              Asked in 1 Companies   Q493. What data structure will you use if we have to search an element in million of elements ?  Data Structure 
  This question was recently asked at 'Microsoft'.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        Search      Asked in 1 Companies   This question was recently asked at 'Veritas'.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   This question was recently asked at 'Veritas'.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   This question was recently asked at 'Veritas'.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   This question was recently asked at 'Veritas'.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        Virtual Memory vs Demand Paging      Asked in 1 Companies   This question was recently asked at 'Veritas'.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        Mutex vs Semaphore      Asked in 1 Companies   Q499. how many reducer task runs on a hadoop cluster ?  BigData 
Ans. Generally one reducer runs for all mappers, but it can be increased as per requirements.   Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve        Hadoop  BigData      Asked in 1 Companies Ans. Access Control List or ACL is the list of permissions attached to an object in the File System.   Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve        acl  file system  file security  object security  operating system  Q501. What is the precedence of operators in Java ?  Core Java 
Ans. http://introcs.cs.princeton.edu/java/11precedence/   Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve        operators  operator precedence       basic   Q502. How do threads share information ?  Core Java 
Ans. Through common memory area.   Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve        threads      Asked in 1 Companies   Q503. Can the foreign key column have null values ?  Database 
  This question was recently asked at 'Volkswagen It services'.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   Q504. Write program to create a linked list and perform different operations on it.  Algorithm 
Ans. import java.util.*; 
class LinkedListSolution{ 
   protected LinkedList list; 
   public LinkedListSolution(){ 
      list = new LinkedList(); 
   } 
   public Object pop() throws NoSuchElementException{ 
      if(list.isEmpty())  
          throw new NoSuchElementException(); 
      else  
          return list.removeFirst(); 
   } 
   public void push(Object obj){ 
      list.addFirst(obj); 
   } 
   public Object peek() throws NoSuchElementException{ 
      if(list.isEmpty())  
          throw new NoSuchElementException(); 
      else  
          return list.getFirst(); 
   } 
   public boolean isEmpty(){ 
      return list.isEmpty(); 
   } 
   public String toString(){ 
      return list.toString(); 
   } 
} 
class TestStack{ 
   public static void main(String args[]){ 
      LinkedListSolution s = new LinkedListSolution(); 
      s.push("First"); 
      s.push("Second"); 
      s.push("Third"); 
      System.out.println("Top: "   s.peek()); 
      s.push("Fourth"); 
      while(!(s.isEmpty())) 
         System.out.println(s.pop()); 
   } 
}   Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve        Linkedlist  data structures  algorithm      Asked in 2 Companies        basic   Q505. How to create list that will sort it's elements dynamically?  Algorithm 
Ans. Override the behavior of collection class to sort the list upon each element addition. Though it's not recommended as list are sorting heavy data structures.  
 
List<MyType> list = new ArrayList<MyType>() { 
    public boolean add(MyType mt) { 
         super.add(mt); 
         Collections.sort(list, comparator); 
         return true; 
    } 
};   Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve              Asked in 1 Companies        intermediate   Q506. Is it advisable to keep session or transaction open for long time just to avoid LazyInitializationException ?  Hibernate 
Ans. No. It's a resource and performance overhead.   Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve        LazyInitializationException  Lazy Loading  Q507. What was the worst problem you faced while working with Hibernate ?  Hibernate 
Ans. Lazy Initialization exceptions   Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve          Q508. What are the disadvantages of Hibernate over native APIs ?  Hibernate 
  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          Q509. Do you like Native SQL Apis like JDBC or JPA / Hibernate ?  Hibernate 
  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        JDBC vs JPA  JDBC vs Hibernate  Q510. If you are given choice to avoid LazyInitializationException using any of the following measures, which are the ones you will choose and why ? 
 
1. Set lazy=false in the hibernate config file. 
2. Set @Basic(fetch=FetchType.EAGER) at the mapping. 
3. Make sure that we are accessing the dependent objects before closing the session. 
4. Force initialization using Hibernate.initialize  Hibernate 
Ans. First resolution is a big No as it conveys no lazy loading in complete app. even second is advocating the same but for a particular mapping. 
 
third one is most appropriate if loading and dependent entity property access is closer to each other in code and can be accomplished.  
 
I don't mind using 4th too.   Help us improve. Please let us know the company, where you were asked this question   :       Like            Discuss            Correct / Improve        lazy loading  lazy initialization  LazyInitializationException