Question: Advantages of MongoDB are as follows:Solution:
- MongoDB supports field, range-based, string pattern matching type queries. for searching the data in the database
- MongoDB support primary and secondary index on any fields
- MongoDB basically uses JavaScript objects in place of procedures
- MongoDB uses a dynamic database schema
- MongoDB is very easy to scale up or down
- MongoDB has inbuilt support for data partitioning (Sharding).
Reference: https://www.interviewbit.com/mongodb-interview-questions/
Question: Write program: get the employee salary > 10000 rupees in the provided list
Solution:
packagecom.test;
importjava.util.*;
importjava.util.stream.Collectors;
publicclassTestEmployee {
publicstaticvoidmain(String... args) {
List<Employee> empList= newArrayList<>();
empList.add(newEmployee("test1", 1235));
empList.add(newEmployee("test2", 12353));
empList.add(newEmployee("test3", 12352));
empList.add(newEmployee("test4", 12345));
empList.add(newEmployee("test5", 1235));
List<String> resEmpList= empList.stream().filter(e-> e.getSalary() > 10000).map(e-> e.getName())
.collect(Collectors.toList());
resEmpList.stream().forEach(System.out::println);
}
}
classEmployee {
privateString name;
privateInteger salary;
publicString getName() {
return name;
}
publicvoidsetName(String name) {
this.name= name;
}
publicInteger getSalary() {
return salary;
}
publicvoidsetSalary(Integer salary) {
this.salary= salary;
}
publicEmployee(String name, Integer salary) {
this.name= name;
this.salary= salary;
}
}
Question: What is docker?
Solution:
Docker is a very popular and powerful open-source containerization platform that is used for building, deploying, and running applications. Docker allows you to decouple the application/software from the underlying infrastructure.
In order to get the status of all the containers, we run the below command:
docker ps -a
docker save command and the syntax is:
docker save -o <exported_name>.tar <container-name>
docker load command and the syntax is
docker load -i <export_image_name>.tar
There are three docker components, they are - Docker Client, Docker Host, and Docker Registry.
- Docker Client: This component performs “build” and “run” operations for the purpose of opening communication with the docker host.
- Docker Host: This component has the main docker daemon and hosts containers and their associated images. The daemon establishes a connection with the docker registry.
- Docker Registry: This component stores the docker images. There can be a public registry or a private one. The most famous public registries are Docker Hub and Docker Cloud.
Reference: https://www.interviewbit.com/docker-interview-questions/
Question: What is Thread life Cycle?
Solution:
The
java.lang.Thread class contains a
static State enum – which defines its potential states. During any given point of time, the thread can only be in one of these states:
- NEW – a newly created thread that has not yet started the execution
- RUNNABLE – either running or ready for execution but it's waiting for resource allocation
- BLOCKED – waiting to acquire a monitor lock to enter or re-enter a synchronized block/method
- WAITING – waiting for some other thread to perform a particular action without any time limit
- TIMED_WAITING – waiting for some other thread to perform a specific action for a specified period
- TERMINATED – has completed its execution
Reference: https://www.baeldung.com/java-thread-lifecycle
Question: What is Hibernate Lifecycle?
Solution:
There are mainly four states of the Hibernate Lifecycle :
- Transient State
- Persistent State
- Detached State
- Removed State
Reference: https://www.geeksforgeeks.org/hibernate-lifecycle/