81.Is there a difference between value object and data transfer object?No. Both are one and the same. 82.What is content negotiation?Suppose we want to visit a site for any information, information can be represented in different languages like English,German or may be other and their format for presentation can also differ from HTML to PDF or may be Plain text. In this case when an client makes an HTTP request to a server, client can also specify the media types here. Client can specify what it can accept back from host and on the basis of availability the host will return to the client. This is called content negotiation because client and server negotiated on the language and format of the content to be shared. 83.What are the different types of memory used by JVM ?Class , Heap , Stack , Register , Native Method Stack. 84.What are the benefits of using Spring Framework ?Spring enables developers to develop enterprise-class applications using POJOs.
The benefit of using only POJOs is that you do not need an EJB container product. 85.What are various types of Class loaders used by JVM ?Bootstrap - Loads JDK internal classes, java.* packages. Extensions - Loads jar files from JDK extensions directory - usually lib/ext directory of the JRE System - Loads classes from system classpath. 86.What is PermGen or Permanent Generation ?The memory pool containing all the reflective data of the java virtual machine itself, such as class and method objects. With Java VMs that use class data sharing, this generation is divided into read-only and read-write areas. The Permanent generation contains metadata required by the JVM to describe the classes and methods used in the application. The permanent generation is populated by the JVM at runtime based on classes in use by the application. In addition, Java SE library classes and methods may be stored here. 87.What is metaspace ?The Permanent Generation (PermGen) space has completely been removed and is kind of replaced by a new space called Metaspace. The consequences of the PermGen removal is that obviously the PermSize and MaxPermSize JVM arguments are ignored and you will never get a java.lang.OutOfMemoryError: PermGen error. 88.How does volatile affect code optimization by compiler?Volatile is an instruction that the variables can be accessed by multiple threads and hence shouldn't be cached. As volatile variables are never cached and hence their retrieval cannot be optimized. 89.What things should be kept in mind while creating your own exceptions in Java?All exceptions must be a child of Throwable. 90.What is the best practice configuration usage for files - pom.xml or settings.xml ?The best practice guideline between settings.xml and pom.xml is that configurations in settings.xml must be specific to the current user and that pom.xml configurations are specific to the project. 91.Can you provide some implementation of a Dictionary having large number of words ?Simplest implementation we can have is a List wherein we can place ordered words
and hence can perform Binary Search.
hashmap {
a ( key ) -> hashmap (key-aa , value (hashmap(key-aaa,value) b ( key ) -> hashmap (key-ba , value (hashmap(key-baa,value) ............................................................ z( key ) -> hashmap (key-za , value (hashmap(key-zaa,value) } upto n levels ( where n is the average size of the word in dictionary. 92.What is database deadlock ? How can we avoid them?When multiple external resources are trying to access the DB locks and runs into
cyclic wait, it may makes the DB unresponsive. 93.Why Web services use HTTP as the communication protocol ?With the advent of Internet, HTTP is the most preferred way of communication. Most of the clients ( web thin client , web thick clients , mobile apps ) are designed to communicate using http only. Web Services using http makes them accessible from vast variety of client applications. 94.Why using cookie to store session info is a better idea than just using session info in the request ?Session info in the request can be intercepted and hence a vulnerability. Cookie can be read and write by respective domain only and make sure that right session information is being passed by the client. 95.Difference between first level and second level cache in hibernate ?1. First level cache is enabled by default whereas Second level cache needs to be
enabled explicitly. 96.What are the ways to avoid LazyInitializationException ?1. Set lazy=false in the hibernate config file. 97.What are new features introduced with Java 8 ?Lambda Expressions , Interface Default and Static Methods , Method Reference , Parameters Name , Optional , Streams, Concurrency. 98.What things you would care about to improve the performance of Application if its identified that its DB communication that needs to be improved ?1. Query Optimization ( Query Rewriting , Prepared Statements ) 2. Restructuring Indexes. 3. DB Caching Tuning ( if using ORM ) 4. Identifying the problems ( if any ) with the ORM Strategy ( If using ORM ) 99.If you are given a choice to implement the code to either Insert a Record or Update if already exist, Which approach will you follow ?1. Insert into the DB Table. If exception occurs, update the existing record. 100.What would you do if you have to add a jar to the project using Maven ?If its already there in Maven local repository, We can add that as a dependency in
the project pom file with its Group Id, Artifact Id and version. |