Hear is Java Architect Questions and Answers
Q1. Can we create system software (Operating-system ) in Java?
Ans. No, Java runs on a virtual machine called JVM, and it does not set well with the hardware. The user can create a platform-independent system software, but it would be slow.
Q2. What are the various types of Classloaders used by JVM?
Ans. Bootstrap which Loads JDK internal classes.
Extensions which Loads jar files from JDK extensions directory are usually lib/ext directory of the JRE
Q3. What is PermGen or Permanent Generation?
Ans. The memory pool is containing all the data of the JVM, such as class and method objects. With Java VMs which use class data sharing, this generation is divided into read-only and read-write areas. The Permanent generation which contains metadata required by the JVM to describe the classes and methods used in the application.
Q4. What is metaspace?
Ans. The Permanent Generation (PermGen) space which has completely been removed and replaced by a new space called Metaspace. The result of the PermGen removal is obviously the PermSize, and MaxPermSize JVM arguments are ignored.
Q5. What is the best practices for configuration usage for files – pom.xml or settings .xml?
Ans. The best practice for 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.
Q6. What is database deadlock? How can we avoid them?
Ans. When multiple external resources are trying to access the database locks and run into the cyclic wait, which may make the DB unresponsive.
Deadlock can be avoided using variety of measures, Few listed below –
Can make a queue wherein we can verify and order the request to DB.
Keeping the transaction smaller.
Q7. Why Web services use HTTP as the communication protocol?
Ans. With the more of the Internet, HTTP is the most preferred way of communication. Most of the clients are designed to communicate using HTTP only. Web Services using HTTP makes them accessible from a vast variety of client applications.
Q8. Why using a cookie to store session info is a better idea than just using session info in the request?
Ans. Session info in the request can be intercepted and therefore vulnerability. A cookie can be read and write by respective domain only and make sure that right session information should pass by the client.
Q 9. State the different between first level and second level cache in hibernate?
- First level cache is enabled by default whereas Second level cache needs to be enabled explicitly.
- First level Cache came with Hibernate 1.0 whereas Second level cache came with Hibernate 3.0.
- First level Cache is Session specific whereas Second level cache is shared by sessions that is why the First level cache is considered local and second level cache is considered global.
Q 10. What are new features introduced with Java 8?
Ans. Lambda Expressions, Default Interface and Static Methods, Method Reference, Parameters Name, Optional, Streams, Concurrency.
Q 11. What kind of software architecture your organization follows?
Ans. We have multi-tier architecture with multiple layers; We have series of web servers and applications in the 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.
Q 12. What would do if you have to add a jar to the project using Maven?
Ans. If it is already there in Maven local repository, the user can add that as a dependency in the project pom file with its Group Id, Artifact Id, and version.
the user can provide additional attribute SystemPath if its unable to locate the jar in the local repository.
If it is not there in the local repository, the user can install it first in the local repository and should add it as a dependency.
Q 13. Which UML diagrams you usually use for design?
Ans. Use Case Diagram, Component Diagram for High-level Design and Class Diagram, Sequence Diagram for low-level design.
Q 14. How do you coordinate and communicate with the team developers?
Ans. The 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 We have daily stand up where we discuss things that need team attention.
Q 15. Difference between Proxy and Adapter Design Patterns
Ans. Adapter object has a different input than the real subject as the Proxy object has the same input as the real subject. The proxy object is such that it should be placed as it is in place of the real subject.
Q 16. State main differences between Adapter and Facade?
Ans. The Difference between these patterns in only the intent. The 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.
Q 17. Difference between Builder and Composite ?
Ans. The builder is a creational Design Pattern whereas Composite is a structural design pattern. Composite creates Parent-Child relations between objects while Builder is used to creating a group of objects of predefined types.
Q 18. Difference between Factory and Strategy Design Pattern?
Ans. The factory is a creational design pattern whereas Strategy is behavioral design pattern. Factory revolves around the creation of an object at runtime whereas Strategy/ Policy revolves around the decision at runtime.
Q 19. Can we use abstract classes or Interfaces in Policy / Strategy Design Pattern?
Ans. Strategy deals only with decision making at runtime so Interfaces can be used.
Q 20. What are things you would care about to improve the performance of Application if it is identified that its DB communication that needs to be improved?
- Query Optimization ( Query Rewriting, Prepared Statements )
- Restructuring Indexes.
- DB Caching ( if using ORM )
- Identifying the problems with the ORM Strategy