Full stack Developer Interview Questions and Answers


Q6: What is MVC and MVP, and how is MVC different from MVP?

Ans: MVC and MVP are both architectural paradigms used in the development of apps.

MVC

  • Model View Controller is an abbreviation for Model View Controller. It is an architectural pattern used in the development of Java Enterprise Applications. It divides an application into three logical components: the Model, the View, and the Controller. It distinguishes between the business-specific logic (Model component) and the display layer (View component).

    The model components include data as well as logically linked to it. The View component is in charge of rendering model objects inside the user interface. Based on handler mapping, the Controller accepts input and invokes model objects. It also sends model objects to views so that output may be shown within the view layer.

MVP

  • MVP is an abbreviation for Model View Presenter. It's based on the MVC architectural pattern. It adds layer (known as indirection) to the architectural design, dividing the View and Controller into View and Presenter. A Presenter takes the position of the Controller. In MVC, it is at the same level as View. It includes the View's UI business logic. The View's invocations are transmitted straight to the presenter. It keeps the activity (events) between the View and the Model going. The presenter does not communicate directly with the View. It connects with the outside world via an interface.

DIFFERENCE

  • The primary distinction between MVC and MVP architectural patterns is that in MVC, the Controller does not transfer data from the Model to the View. It merely informs the View that the data is available from the Model. The View and Model layers are linked in the MVP architectural pattern. The presenter gets data from the Model and transmits it to the View for display. Another distinction is that MVC is frequently used in web frameworks, whereas MVP is utilized in app development.

Q7: What are continuous integration and continuous delivery (CI/CD)?

Ans: CI/CD is a best practice for developing apps with frequent and quick code changes. It is also known as the CI\CD pipeline. It is frequently utilized in DevOps and agile methodologies. Continuous integration is a coding philosophy or deployment technique in which developers integrate their code multiple times per day in a common repository. Because modern applications necessitate the development of code across several platforms. Continuous integration aims to provide an automated system for building, testing, and packaging applications. Where CI ends, continuous delivery begins. It automatically deploys the application to the infrastructure of choice. If any modifications are made to the code, CD guarantees that the code is delivered automatically.

Q8: Explain semantic HTML with an example and why we should use it?

Ans: The concept of utilizing HTML components to identify what they are in web design. It is referred to as semantic HTML or semantic markup. .
Semantic HTML is HTML that represents a meaning to a web page rather than just presentation. Tag < p >, for example, indicates that a paragraph is surrounded in it. It is both semantic and presentational since the user understands what paragraphs are, and the browser shows them. Tags such as < b > and < I> , on the other hand, are not semantic. They merely indicate how text should appear. These tags add no meaning to the markup.

Header tags are an example of semantic HTML tags < h1 > to < h6 >, < abbr >, < cite >, < tt >, < code >, < blockquote >, < em >, etc. Other semantic HTML elements are used to construct a standards-compliant website.

The semantic HTML should be used for the following reasons:

  • It adds information about the document in which it is utilized. It also helps with communication.
  • Semantic tags inform the browser about the meaning of a page and its content.
  • It offers information about the tags' contents that extends beyond how they appear on a page.
  • It provides us with a plethora of new hooks for customizing the page's content.
  • The semantic tag's clarity is also transmitted to search engines, guaranteeing that the appropriate pages are delivered for the right searches.

Q9: How to avoid deadlock in Java?

Ans:

  • Avoid Unnecessary Locks:  We should only utilize locks on those members who require them. Unnecessary usage of locks results in a deadlock. It is advised to adopt a lock-free data structure. If at all feasible, maintain your code free of locks. ConcurrentLinkedQueue, for example, can be used instead of synchronized ArrayList.
  • Avoid Nested Locks:  Another method to avoid deadlock is not to give a lock to many threads if we have already given a lock to one because we don't want to assign a lock to many threads.
  • Using Thread. Join () Method:  Another method to avoid deadlock is not giving a lock to many threads if we have already given one because we don't want to assign a lock to many threads.
  • Use Lock Ordering: Each lock should always be assigned a numerical value. Before purchasing a lock with a higher numeric value, purchase a lock with a lower numeric value.
  • Lock Time-out:  We may also specify how long it takes for a thread to obtain a lock. If a thread fails to obtain a lock, it must wait a certain amount of time before attempting to acquire a lock again.

Q10: What is Inversion of Control?

Ans: Inversion of control is a wide phrase, but for a software engineer, it is most frequently defined as a technique used to decouple system components and levels. Assume your application has a text editor and you wish to include spell checking. This is how your typical code would look:

public class TextEditor { private SpellChecker checker; public TextEditor() { this.checker = new SpellChecker(); } } We've created a dependence between the TextEditor and the SpellChecker here. In an IoC situation, we would instead do the following: public class TextEditor { private IocSpellChecker checker; public TextEditor(IocSpellChecker checker) { this.checker = checker; } } You have reversed control by delegating instantiating the spell checker from the TextEditor class to the caller. SpellChecker sc = new SpellChecker; // dependency TextEditor textEditor = new TextEditor(sc);