Once again, I’ve searched through everything and found no answers. Well, I’ll post mine, although I wrote them purely for myself and as briefly as possible. But anything is better than nothing. So, the questions were: Interview questions:
- What is MVC?
- What is DAO and DTO?
- What is Pa OJO?
- What is an entity?
- What collection lists do you know?
- What set collections do you know?
- What is a map, and how is it different from a dictionary?
- What is a queue and a deque?
- What classes do you know that implement the Queue interface?
- What is a tree?
And now my answers:
- MVC is a design pattern that divides an application into three distinct parts: the model, the view, and the controller. The model provides data and responds to the controller’s commands by changing its state. The view is responsible for displaying model data to the user and responding to changes in the model. The controller interprets user actions, notifying the model of the need for changes. Thus, each component of this pattern is loosely coupled to the other components, achieving program flexibility. Most often, all business logic is located in the model, although it is sometimes also contained in the controller. In the former case, the model is called thin; in the latter, thick.
- A DAO (Data Access Object) is an object whose primary purpose is to store data in and retrieve it from a database. A DTO (Data Transfer Object) is an object designed for data transport. Therefore, its primary purpose is to store this data. It contains no logic. Furthermore, it must be serializable, as transporting objects typically occurs through serialization and deserialization.
- POJO stands for “Plain Old Java Object.” They are contrasted with EJBs, which follow a specific convention and are usually tightly bound to a specific enterprise framework (for example, they must have a public parameterless constructor, getters and setters for fields, be serializable, etc.). A POJO is, accordingly, a regular class that doesn’t inherit from any special classes or implement any special interfaces. Typically, a POJO doesn’t do anything special and contains only state.
- An entity bean is a bean whose purpose is to store data. Its logic includes a mechanism for saving itself and its fields to the database. Such an object can be destroyed and then recreated from the database. However, other than storing data, it has no logic. A bean, in turn, is a special class that must adhere to the following rules:
- The class must have a parameterless constructor with the public access modifier. This constructor allows tools to create an object without the additional complexity of parameterization.
- Class properties must be accessible via get, set, and other methods (called accessor methods), which must adhere to a standard naming convention. This allows tools to easily automatically detect and update bean contents. Many tools even have specialized editors for different property types.
- The class must be serializable. This allows the bean’s state to be reliably saved, stored, and restored in a platform- and virtual machine-independent manner.
- The class must have overridden equals(), hashCode(), and toString() methods.
- All list collections implement the List<E> interface and inherit from the abstract class AbstractList<E>. Among them, ArrayList<E> and LinkedList<E> stand out. ArrayList<E> is a list based on an array, and LinkedList<E> is a classic doubly linked list.
- Set collections in Java implement the Set<E> interface and inherit from AbstractSet<E>. Sets are collections of data in which all elements are unique. Among these in Java are HashSet, LinkedHashSet, and TreeSet. The first collection stores its objects based on hash codes. The second is a modified version of the first, in which its elements are also arranged in a linked list, so they are all listed in insertion order. The third collection provides sorting of its elements.
- A Map is a type of collection that stores its elements as key-value pairs. All keys must be unique. Implementations include HashMap and TreeMap. The former stores elements using hash codes. The latter stores elements sorted by key.
- A queue is a first-in, first-out data structure. Elements are added to the queue at one end and removed from the other. A deque is a double-ended queue. Elements can be added to the front or back of the queue, and elements can be retrieved from both the front and back. Accordingly, there are methods for adding an element (these are the add(e) and offer(e) methods), and there are methods for removing an element from the queue (these are methods such as remove() and poll()). There are also methods for simply getting an element from the queue without removing it (these are the element() and peek() methods). The Deque interface also includes methods for adding elements to the front and back of the queue, removing elements from the front or back, and getting elements from the front or back of the queue (without removing them from the queue).
- Simple implementations include ArrayDeque, LinkedList, and PriorityQueue. There are also many classes in Concurrent Collections that implement these two interfaces (either both or just one).
- A tree is a connected graph without loops and multiple edges. Typically, if a tree has N vertices, then the minimum number of edges is N-1. Also, one vertex in the tree is chosen as the root. The remaining vertices are declared branches. Branches that do not have their own branches are called leaves of the tree.
Trees are used quite widely in programming, and many types of trees have already been invented. One of the most widely used trees is the binary tree. In this tree, each element has no more than two descendants (that is, it can have from 0 to 2). One type of binary tree is the BST (binary search tree. In this tree, the elements are ordered by a rule: the left child of an element must be less than the element in value, and the right child must be greater than or equal to it.
Red-black trees also exist. This is a type of binary search tree. Red-black trees introduce another property of the element: color. The color can be black or red. Also, every red-black tree must satisfy the following requirements:- the root of the tree is black;
- the knot is either red or black;
- all the leaves of the tree are black;
- both descendants of the red node are black;
- every path from a given node to any leaf node that is its descendant contains the same number of black nodes.
These rules help ensure tree balance. A tree is balanced when the path length from the root to any leaf node differs by no more than 1. (In other words, the tree has no distortions or long branches.)

