InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Shall We Use Abstract Classes Or Interfaces In Policy / Strategy Design Pattern ? |
|
Answer» STRATEGY deals only with DECISION MAKING at runtime so INTERFACES should be used. Strategy deals only with decision making at runtime so Interfaces should be used. |
|
| 2. |
Difference Between Factory And Strategy Design Pattern ? |
|
Answer» Factory is a creational design PATTERN whereas STRATEGY is behavioral design pattern. Factory REVOLVES around the creation of OBJECT at runtime whereas Strategy or POLICY revolves around the decision at runtime. Factory is a creational design pattern whereas Strategy is behavioral design pattern. Factory revolves around the creation of object at runtime whereas Strategy or Policy revolves around the decision at runtime. |
|
| 3. |
Difference Between Builder And Composite ? |
|
Answer» Builder is a creational Design Pattern WHEREAS COMPOSITE is a structural design pattern. Composite creates PARENT - Child relations between your objects while Builder is used to CREATE group of objects of PREDEFINED types. Builder is a creational Design Pattern whereas Composite is a structural design pattern. Composite creates Parent - Child relations between your objects while Builder is used to create group of objects of predefined types. |
|
| 4. |
Difference Between Adapter And Facade ? |
|
Answer» The Difference between these patterns in only the intent. Adapter is used because the OBJECTS in current form cannot communicate where as in Facade , THOUGH the objects can communicate , A Facade object is placed between the client and subject to SIMPLIFY the INTERFACE. The Difference between these patterns in only the intent. Adapter is used because the objects in current form cannot communicate where as in Facade , though the objects can communicate , A Facade object is placed between the client and subject to simplify the interface. |
|
| 5. |
Difference Between Proxy And Adapter Design Patterns ? |
|
Answer» Adapter OBJECT has a DIFFERENT input than the real SUBJECT whereas Proxy object has the same input as the real subject. Proxy object is such that it should be placed as it is in place of the real subject. Adapter object has a different input than the real subject whereas Proxy object has the same input as the real subject. Proxy object is such that it should be placed as it is in place of the real subject. |
|
| 6. |
What Kind Of Software Architecture Your Organization Follow ? |
|
Answer» We have multi tier architecture with multiple layers , We have series of WEB servers and applications in application tier, infrastructure libraries at middle tier and Database servers at the LOWER tier. We are USING ORACLE as Database, ESB ( Enterprise service Bus ) for asynchronous communication and Rest Web Services. We have multi tier architecture with multiple layers , We have series of web servers and applications in application tier, infrastructure libraries at middle tier and Database servers at the lower tier. We are using Oracle as Database, ESB ( Enterprise service Bus ) for asynchronous communication and Rest Web Services. |
|
| 7. |
How Do You Coordinate And Communicate With The Team Developers ? |
|
Answer» We as a TEAM of developers , testers , ANALYST , LEAD and architect sit close to each other. Most of the time I would just jump to their SEAT and talk to them ( if required ). We have daily stand up where we discuss things that needs team attention. We as a team of developers , testers , analyst , lead and architect sit close to each other. Most of the time I would just jump to their seat and talk to them ( if required ). We have daily stand up where we discuss things that needs team attention. |
|
| 8. |
Which Uml Diagrams You Usually Use For Design ? |
|
Answer» USE CASE DIAGRAM, Component Diagram for High LEVEL Design and Class Diagram , Sequence Diagram for low level design. Use Case Diagram, Component Diagram for High level Design and Class Diagram , Sequence Diagram for low level design. |
|
| 9. |
What Would You Do If You Have To Add A Jar To The Project Using Maven ? |
|
Answer» 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. We can provide additional attribute SystemPath if its unable to locate the jar in the local repository. If its not there in the local repository, we can INSTALL it first in the local repository and then can add it as dependency. 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. We can provide additional attribute SystemPath if its unable to locate the jar in the local repository. If its not there in the local repository, we can install it first in the local repository and then can add it as dependency. |
|
| 10. |
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. 2. Check If The Record Exists And Update It If It Exists, If Not Insert A New Record. |
|
Answer» In first case, there would be 2 DB calls in WORST case and 1 in BEST case. In 2nd approach there will be always 2 DB calls. Decision on the approach should depend on the following CONSIDERATIONS - 1. How costly is the call to DB. Are we using indices , hibernate etc If calls to DB are costly , 1st approach should be the choice. 2. Exception Book KEEPING load upon exception. The benefit of SAVING 1st call in approach 1 should be bigger than the Book keeping for the exception. 3. Probability of the exception in first apparoach. If the DB Table is almost empty, it makes sense to follow Approach 1 as majority of the 1st calls will pass through without exception. In first case, there would be 2 DB calls in worst case and 1 in best case. In 2nd approach there will be always 2 DB calls. Decision on the approach should depend on the following considerations - 1. How costly is the call to DB. Are we using indices , hibernate etc If calls to DB are costly , 1st approach should be the choice. 2. Exception Book keeping load upon exception. The benefit of saving 1st call in approach 1 should be bigger than the Book keeping for the exception. 3. Probability of the exception in first apparoach. If the DB Table is almost empty, it makes sense to follow Approach 1 as majority of the 1st calls will pass through without exception. |
|
| 11. |
What Things You Would Care About To Improve The Performance Of Application If Its Identified That Its Db Communication That Needs To Be Improved ? |
Answer»
|
|
| 12. |
What Are New Features Introduced With Java 8 ? |
|
Answer» Lambda Expressions , Interface DEFAULT and STATIC Methods , Method Reference , Parameters NAME , Optional , Streams, CONCURRENCY. Lambda Expressions , Interface Default and Static Methods , Method Reference , Parameters Name , Optional , Streams, Concurrency. |
|
| 13. |
What Are The Ways To Avoid Lazyinitializationexception ? |
| Answer» | |
| 14. |
Difference Between First Level And Second Level Cache In Hibernate ? |
Answer»
|
|
| 15. |
Why Using Cookie To Store Session Info Is A Better Idea Than Just Using Session Info In The Request ? |
|
Answer» 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. 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. |
|
| 16. |
Why Web Services Use Http As The Communication Protocol ? |
|
Answer» 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. 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. |
|
| 17. |
What Is Database Deadlock ? How Can We Avoid Them? |
|
Answer» When multiple external resources are trying to access the DB locks and runs into cyclic WAIT, it may makes the DB unresponsive. Deadlock can be AVOIDED using VARIETY of measures, Few listed below:
When multiple external resources are trying to access the DB locks and runs into cyclic wait, it may makes the DB unresponsive. Deadlock can be avoided using variety of measures, Few listed below: |
|
| 18. |
Can You Provide Some Implementation Of A Dictionary Having Large Number Of Words ? |
|
Answer» Simplest implementation we can have is a List wherein we can PLACE ordered WORDS and HENCE can perform Binary Search. Other implementation with better search performance is to use HashMap with key as first character of the WORD and value as a LinkedList. Further level up, we can have linked Hashmaps like , 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. Simplest implementation we can have is a List wherein we can place ordered words and hence can perform Binary Search. Other implementation with better search performance is to use HashMap with key as first character of the word and value as a LinkedList. Further level up, we can have linked Hashmaps like , 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. |
|
| 19. |
How Does Volatile Affect Code Optimization By Compiler? |
|
Answer» 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. 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. |
|
| 20. |
What Is Metaspace ? |
|
Answer» 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. 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. |
|
| 21. |
What Is Permgen Or Permanent Generation ? |
|
Answer» 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. 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. |
|
| 22. |
What Are Various Types Of Class Loaders Used By Jvm ? |
|
Answer» 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. 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. |
|
| 23. |
What Are The Benefits Of Using Spring Framework ? |
Answer»
|
|
| 24. |
What Are The Different Types Of Memory Used By Jvm ? |
|
Answer» Class , Heap , STACK , REGISTER , Native METHOD Stack. Class , Heap , Stack , Register , Native Method Stack. |
|
| 25. |
Should We Create System Software ( E.g Operating System ) In Java ? |
|
Answer» No, Java runs on a virtual machine CALLED JVM and HENCE doesn't embed well with the underlying hardware. Though we can CREATE a PLATFORM independent system software but that WOULD be really slow and that's what we would never need. No, Java runs on a virtual machine called JVM and hence doesn't embed well with the underlying hardware. Though we can create a platform independent system software but that would be really slow and that's what we would never need. |
|