Interview Questions and Answers - Order By Newest Q721. Can we add heterogeneous elements into TreeMap ?
Ans. No, Sorted collections don't allow addition of heterogeneous elements as they are not comparable. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   comparable interface   treemap Q722. Will it create any problem if We add elements with key as user defined object into the TreeMap ?
Ans. It won't create any problem if the objects are comparable i.e we have that class implementing Comparable interface. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   treemap   comparable interface Q723. Can we have null keys in TreeMap ? Core Java
Ans. No, results in exception. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   treemap Asked in 6 Companies Basic   frequent Q724. Can value be null in TreeMap ? Core Java
Ans. Yes. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   treemap   yes-no Q725. Which interface TreeMap implements ?
Ans. TreeMap implements NavigableMap, SortedMap, Serializable and Clonable. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   treemapFrequently asked in Phone Interviews. Q726. What the Bean scopes provided by Spring ? Spring
Ans. Singleton , Prototype , Request , Session , global-session Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  spring framework   bean scope   general electric   geFrequently asked in Phone Interviews. Q727. What are the various Auto Wiring types in Spring ?
Ans. By Name , By Type and Constructor. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   spring   spring container   dependency injection   auto wiring   auto wiring types   general electric   ge Q728. What are the the methods to clear cache in Hibernate ? Hibernate
Ans. Evict() and clear(). Evist is used to clear a particular object from the cache whereas clear clears the complete local cache. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   orm   hibernate cache Q729. What are different types of second level cache ? Hibernate
Ans. 1. EHCache ( Easy Hibernate )
2. OSCache ( Open Symphony )
3. Swarm Cache ( JBoss )
4. Tree Cache ( JBoss ) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   orm   hibernate cache   technical lead Asked in 7 Companies Q730. Can we disable first level cache ? What should one do if we don't want an object to be cached ? Hibernate
Ans. No.We can either call evict after the object retrieval or can use separate sessions. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   orm   hibernate cache   architectureAns. Hibernate is a Java ORM Framework. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   orm   frameworks   architecture Q732. What are the different types of inheritance in Hibernate ? Hibernate
Ans. Table Per Class , Table per Sub Class , Table per Concrete Class Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   orm   inheritance hibernate Asked in 1 Companies Basic   frequent Q733. What is lazy fetching in Hibernate ? Hibernate
Ans. Lazy fetching is the technique of not loading the child objects when parent objects are loaded. By default Hibernate does not load child objects. One can specify whether to load them or not while doing the association. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   lazy fetching   architecture Asked in 11 Companies   frequent Try 2 Question(s) Test Q734. Is It Good to use Reflection in an application ? Why ? Core Java
Ans. no, It's like challenging the design of application. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   reflection api   yes-no   architecture Asked in 1 Companies intermediate Q735. Why is Reflection slower ?
Ans. Because it has to inspect the metadata in the bytecode instead of just using precompiled addresses and constants. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   reflection   reflection api   architecture Q736. When should we use prototype scope and singleton scope for beans ? Spring
Ans. We should use singleton scope for beans when they are stateless and prototype when they are stateful. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  spring   bean scope   general electric   ge  singleton Q737. Difference between Assert and Verify ? Testing
Ans. Assert works only if assertions ( -ea ) are enabled which is not required for Verify.Assert throws an exception and hence doesn't continue with the test if assert evaluates to false whereas it's not so with Verify. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  assert   junit   mockito   verify   testing   unit testing Asked in 5 Companies Q738. How many SessionFactory and Session objects are created ? Java EE
Ans. Single SessionFactory object and multiple session objects for opening different session. Hibernate creates new Session object per thread. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   sessionfactory hibernate   session hibernate Q739. What is the use of hbm2ddl Configuration in Hibernate ? Hibernate
Ans. This configuration specifies if hibernate should creates the Schema / Table on its own if the respective table is not found. "update" doesn't create the table if it's not found whereas configuration set as "create" creates the schema automatically. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   hibernate configuration   hibernate.cfg.xml   hbm2ddl Q740. What are the different ID generating strategies using @GeneratedValue annotation ? Hibernate
Ans. Auto , Identity , Sequence and Table. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   generatedvalue annotations   architecture Q741. How to do Eager loading in Hibernate ? Hibernate
Ans. Using lazy = false in hibernate config file or @Basic(fetch=FetchType.EAGER) at the mapping Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   lazy loading hibernate   basic annotation hibernate   architectureAns. Instead of Saving Parent as well as Child Entities individually , Hibernate provides the option to persist / delete the related entities when the Parent is persisted. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   cascade   hibernate relationship   hibernate associations Q743. What are the different Cascade types ? Hibernate
Ans. Detach, Merge , Persist , Remove , Refresh Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   cascade   cascade type Q744. Which type of associated Entities are Eagerly loaded by Default ? Hibernate
Ans. OneToOne Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   hibernate associations   hibernate relationship Q745. Can we declare Entity class as final ? Hibernate
Ans. Yes but as Hibernate creates the Proxy Classes inherited from the Entity Classes to communicate with Database for lazy initialization. Declaring entity classes as final will prohibit communication with database lazily and hence will be a performance hit. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   proxy objects   proxy classes   entity hibernate Q746. What is the difference between int[] x; and int x[]; ? Core Java
Ans. No Difference. Both are the acceptable ways to declare an array. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   array   arrays   array declaration   difference between Asked in 3 Companies basic Q747. What is asynchronous I/O ?
Ans. It is a form of Input Output processing that permits other processing to continue before the I/O transmission has finished. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   io   file   fileio   java7   architectureFrequently asked these days as there are major changes in Java 8. Q748. What are new features introduced with Java 8 ? Core Java
Ans. Lambda Expressions , Interface Default and Static Methods , Method Reference , Parameters Name , Optional , Streams, Concurrency. Sample Code for Lambda Sample Code for interface default Sample Code for Optional Sample Code for Streams Sample Code for java.time Sample Code for Predicate Sample Code for Consumer Sample Code for MapMerge Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java8   technical lead   technical architect Asked in 14 Companies expert   frequent Rarely asked as default methods have been introduced with Java 8. Q749. Can we have a default method without a Body ? Core Java
Ans. No. Compiler will give error. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java8   default method   yes-no   rare Rarely asked as default methods have been introduced with Java 8. Q750. Can we have a default method definition in the interface without specifying the keyword "default" ? Core Java
Ans. No. Compiler complains that its an abstract method and hence shouldn't have the body. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java8   default methods   default keyword   yes-no