3)hibernate which version you used in ur project nd what are the updates 4)spring which version used in the project and what re the changes 5)hibernate mapping 6)when to use list,set and map -Done 7)what is IOC 8)scopes in spring-Done 9)Dependency Injection- Done 10)what is Error and example- Done 11)Spring annotations 12)what persistance.xml will do 15)how do we connect to DB through code(what do we implement in DAO class) 16)toString(), hashCode() and equals()...? 17)Criteria Query 18)How to remove duplicates from a String public static void removeDuplicateString2(String input) { Set<Character> set= new LinkedHashSet<Character>(); for(int i=0;i<input.length();i++){ set.add(input.charAt(i)); } StringBuilder stringBuilder= new StringBuilder(); for(Character character:set){ stringBuilder.append(character); } System.out.println(stringBuilder); } 19)Can we override the main methodyes we can override the main method 20)Can we have a method with the same name as class name? Yes we can have a method with the class name. 21)How to make a class immutable(rules) 1. Declare the class as final so it can't be extended. 2. Make all fields private so that direct access is not allowed. 3. Don't provide setter methods for variables. 4. Make all mutable fields final so that it's value can be assigned only once 5. Initialize all the fields via a constructor performing deep copy. 6. Perform cloning of objects in the getter methods to return a copy rat her than returning the actual object reference. 22)Differece between HashSet and TreeSet? 1. Ordering: HashSet will give the values randomly where as Treeset will sort the elemets using natural sorting order or we can use compareto methoed to sort the elemets. 2. Null vale: Hashset will can store null object, where as treeSet will not. 3. Comparison: Hashset uses equals method for comparision while TreeSet uses compareTo() for maintaining order. 4. Functionality: TreeSet is rich functionality compared with HashSet be cuase of the methods like pollFrirst(), ceil(),las(), pollLast() etc. 5. Performance and Speed: HashSet takes constant time for persforming op erations like add, remove, contains while TreeSet will yke log(n) time cost for performing basic opertaions. TreeSet uses Red- Black tree algorithm underneath to sort out the elements. When one need to perform read/write operations frequently , then TreeSet is a good c hoice. Fail-fast Iterators : The iterators returned by this class's method are fail-f ast: if the set is modified at any time after the iterator is created, in any w ay except through the iterator's own remove method, the iterator will throw a
ConcurrentModificationException. Thus, in the face of concurrent modification,
the iterator fails quickly and cleanly, rather than risking arbitrary, non-deter ministic behavior at an undetermined time in the future. 23)Design patterns in java These are ctaogorized into 3 types: they are 1. Creational Design patterns: Singleton Design pattern, Factory patters n, Abstarct factory pattery, prototype pattern, builder pattern 2. Structural Design patterns: adapter pattern, proxy pattern, Facade pa tterns, decorator pattern 3. Behavioural Design patterns: Stategy pattern, absorver pattern, state pattern, iternator pattern,visitor pattern. 24)How to make a class as Singleton and what is the use of singleton classes 1. Private constructor to restrict instantiation of the class from other classes. 2. Private static variable of the same class that is the only instance o f the class. 3. Public static method that returns the instance of the class, this is the global access point for outer world to get the instance of the singleton cla ss. example: package com.journaldev.singleton; public class EagerInitializedSingleton { private static final EagerInitializedSingleton instance = new EagerInitializ edSingleton(); //private constructor to avoid client applications to use constructor private EagerInitializedSingleton(){} public static EagerInitializedSingleton getInstance(){ return instance; } }