Java Architect Interview Questions and Answers (2021)
- Q: What does SOLID stand for? What are its principles?
- Q: What is the difference between Monolithic, SOA and Microservices Architecture?
- Q: What are the differences between continuous integration, continuous delivery, and continuous deployment?
- Q: What is the difference between Concurrency and Parallelism?
- Q: What is Domain Driven Design?
- Q: Explain the Single Responsibility Principle (SRP)?
- Q: Do you familiar with The Twelve-Factor App principles?
- Q: What is MetaSpace in Java8? How does it differ from PermGen Space?
- Q: How Does Volatile Affect Code Optimization By Compiler?
Q: What is SOLID principles?
S.O.L.I.D is an acronym for the first five principles of object-oriented design (OOD) by Robert C. Martin, which stands from
- S - Single-responsiblity principle : A class should have one reason to change, which means that a class should only have one job.
- O - Open-closed principle : Objects / entities should be open for extension, but closed for modification.
- L - Liskov substitution principle : Let q(x) be a property provable about objects of x of type T. Then q(y) should be provable for objects y of type S where S is a subtype of T.
- I - Interface segregation principle : A client should never be forced to implement an interface that it does not use, or clients should not be forced to rely on methods that they do not use.
- D - Dependency Inversion Principle : Entities must depend on abstractions, not concreteness. It states that the high-level module must not depend on the low-level module, but should depend on abstractions.
Q: What is the difference between Monolithic, SOA and Microservices Architecture?The aim of the LTS version is to complete the preview capabilities so that they are stable enough and look good for the next three years.
- Monolithic Architecture is analogous to a large container in which all software elements of the application are assembled together and wrapped tightly.
- Service-Oriented Architecture is a set of services that interact with each other. Communication may involve either simple transmission of data or may involve two or more services coordinating such activities.
- Microservice Architecture is an architectural style that constructs an application as a series of small autonomous services, modeled around a business domain.
Q: What is continuous integration, continuous delivery, and continuous deployment?
Continuous Integration and continuous Delivery (CI/CD) is a set of software practices and techniques that enable the frequent release of small batches of code changes, with extensive visibility and traceability. It typically involves the creation of a largely automated pipeline that orchestrates the build, test and deployment of software across staged environments, ultimately leading to deployment in production.
- Continuous Integration : Developers merge their changes back to the main branch as much as possible, instead of waiting for the release day to integrate their changes into the release branch.
- Continuous delivery : is an extension of continuous integration to ensure that new improvements can be made easily and sustainably to the customers. This means that, in addition to getting your testing automated, you have also automated your release process and can deploy your application at any time by clicking on a button.
- Continuous delivery is one step beyond continuous delivery, with this any change that passes through all stages of your production pipeline is released to your customers. There is no human interference, and only a failed test can prevent a new improvement from being introduced to production.
Q: Do you familiar with The Twelve-Factor App principles?The 12-factor app approach is a technique for software development as a service. These best practices are intended to allow portability and resilience web applications to be developed.
- Codebase : Central one codebase for a deployed service tracked in revision control with the codebase being used for many deployments.
- Dependencies : Explicitly declare and isolate dependencies. All dependencies should be declared, with no implicit reliance on system tools or libraries.
- Config : Store config in the environment. Configuration that varies between deployments should be stored in the environment.
- Backing services : Treat backing services as attached resources. All backing services are treated as attached resources and attached and detached by the execution environment.
- Build, release, run : Strictly separate build and run stages. The delivery pipeline should strictly consist of build, release, run.
- Port binding : Export services as port binding. Self-contained services should make themselves available to other services by specified ports.
- Concurrency : Scale out via the process model. Concurrency is advocated by scaling individual processes.
- Dev/Prod parity : Keep development, staging and production as similar as possible. All environments should be as similar as possible.
- Logs : Treat log as event stream. Applications should produce logs as event streams and leave the execution environment to aggregate.
- Admin Processes : Run admin/management tasks as one-off process. Any needed admin tasks should be kept in source control and packaged with the application.
Q: What was enhanced for Z Garbage Collector (ZGC)?
JDK 11 has introduced
Z Garbage Collector (ZGC), which had short pause while cleaning up the heap memories and it was not returning unused memory to operating system even though memory was unused for long time. Now Java
13 has extended the feature to return unused heap memory to the operating system.
Click on link to know more about Z Garbage Collector
Q: What is Domain Driven Design?
Domain driven design is a methodology and process prescription for developing complex systems which focus on mapping into the technical objects of a solution area activities, tasks, events and data within a problem field. It's all about making your software a real system or process model.
Take a look at our suggested post on Java :
Q: When should I use a NoSQL database instead of a relational database?
Relational databases enforce the ACID. So, you can have schema-based data stores that are transaction-oriented. For 99 percent of real world applications, it is proven and suitable. With relational databases, you can basically do anything.
when it comes to large high-availability data stores, there are speed and scaling limitations. Google and Amazon have terabytes of data stored in large data centers, for example. In these cases, querying and inserting is not successful because of the blocking/schema/transaction nature of the RDBMs.
That is why, for huge performance benefit and scalability, they have introduced their own databases (actually, key-value stores).
- We use NoSQL db usually when:
- Client requires 99.999 percent availability at high traffic sites.
- Your data doesn't make any sense in SQL, you find yourself doing multiple JOIN queries to access some piece of information.
- you split the relational model, have CLOBs that store denormalized data, and create external indexes to search for that data.
Q: What is Permgen (Permanent Generation) ?
A memory pool that contains all of the Java Virtual Machine's own reflective data, such as class and method objects. With Java VMs that use data sharing class, this generation is divided into read-only and read-write areas.
Permanent Generation contains the metadata needed by the JVM for the application to define the classes and methods used. At runtime, the permanent generation is populated by the JVM based on classes in the application's use. Moreover, the classes and methods of the Java SE library can be stored here.
Q: What is MetaSpace in Java8? How does it differ from PermGen Space?
The Permanent Generation (PermGen) space has been removed completely with JDK8 and is kind of replaced by a new space called Metaspace.
This metadata is now stored as "MetaSpace" in the native memory. This memory is not a Java Heap contiguous memory. It allows for improvements in the collection of garbage space over PermGen space, auto tuning, concurrent metadata de-allocation.
The result of the PermGen elimination is that the PermSize and MaxPermSize JVM arguments are obviously ignored and you will never receive an error with java.lang.OutOfMemoryError: PermGen.
Q: How Does Volatile Affect Code Optimization By Compiler?
Volatile is an instruction that multiple threads will access the variables and should therefore not be cached. Because volatile variables are never cached, their retrieval can therefore not be optimized.