Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Interview Java question

1. Hỏi về dự án củ
2. Kể lại quá trình làm app và tét của bản thân ?
3. Hỏi về mô hình Agile Scrum ? Quy trình làm app hiện tại là gì ?
4. Cách triển khai và deploy một dự án spring boot ?
5. Nếu có 2 user cùng lúc update một record trong cùng một khoảng thời gian
thì làm cách nào để tránh ?
6. SQL injection là gì ? Làm thế nào để giảm bớt SQL injection ?
• Prepared Statements with Parameterized Queries: Always ensure that your
SQL interpreter always able to differentiate between code and data. Never use dynamic
queries which fail to find the difference between code and data. Instead, use static SQL
query and then pass in the external input as a parameter to query. Use of Prepared
Statements (with Parameterized Queries) force developer to first define all the SQL code,
and then pass in each parameter to the query later.
• Use of Stored Procedures: Stored Procedure is like a function in C where
database administrator call it whenever he/she need it. It is not completely mitigated SQL
injection but definitely helps in reducing risks of SQL injection by avoiding dynamic
SQL generation inside.
• White List Input Validation: Always use white list input validation and allow
only preapproved input by the developer. Never use blacklist approach as it is less secure
than whitelist approach.
• Escaping All User Supplied Input
• Enforcing Least Privilege
6. What are the different bean scopes in spring?
There are 5 bean scopes in spring framework.
No. Scope Description
1) singleton The bean instance will be
only once and same
instance will be returned
by the IOC container. It is
the default scope.
2) prototype The bean instance will be
created each time when
requested.
3) request The bean instance will be
created per HTTP request.
4) session The bean instance will be
created per HTTP session.
5) globalsession The bean instance will be
created per HTTP global
session. It can be used in
portlet context only.
7. Can you tell the difference between equals() method and equality operator
(==) in Java?
equals() ==
This is a method defined in the Object It is a binary operator in Java.
class.
This method is used for checking the This operator is used for comparing
equality of contents between two objects addresses (or references), i.e checks if
as per the specified business logic. both the objects are pointing to the
same memory location.
8. Hiểu như thế nào về overload ?
9. What are the differences between Heap and Stack Memory in Java?
Stack is generally used to store the order of method execution and local variables. In
contrast, Heap memory is used to store the objects. After storing, they use dynamic
memory allocation and deallocation.
9. What are the differences between HashMap and HashTable in Java?
HashMap HashTable
HashMap is not synchronized thereby HashTable is synchronized and hence it
making it better for non-threaded is suitable for threaded applications.
applications.
Allows only one null key but any This does not allow null in both keys or
number of null in the values. values.
Supports order of insertion by making Order of insertion is not guaranteed in
use of its subclass LinkedHashMap. HashTable.
1. Phân biệt interface và abstract ?
Methods: Class abstract có các phương thức abstract và non-abstract. Trong
khi Interface chỉ có phương thức abstract, từ Java 8, thì Interface có thêm 2 loại phương
thức là default và static.
Variables: Class abstract có thể có các biến final, non-final, static và non-static. Trong
khi Interface chỉ có các biến static và final.
Implementation: Class abstract có thể implement các Interface. Trong khi Interface thì
không thể implement class abstract.
Inheritance: Class abstract có thể kế thừa được một class khác. Trong khi Interface có thể
kế thừa được nhiều Interface khác.
Accessibility: các thành viên trong Interface kiếu mặc định là public. Trong khi
class abstract thì lại có thể là private, protected,..
6. Giải thích về JWT ? Tại sao lại sử dụng JWT ?
7. Khái niệm indepencde Injection là gì ?
8. Khái niệm Bean và cách thay đổi giá trị Bean ?
9. Cách theo dõi log như thế nào ? Liên tưởng tới mô hình ELK bao gồm những
thành phần nào ?
The ELK Stack consists of three open-source products - Elasticsearch, Logstash, and
Kibana from Elastic.

10. Hỏi về dữ liệu cached mô tả bằng dữ liệu đường phố ?


11. Hiểu như thế nào về @Transaction
12. Question: What are the main components of Microservices?
Answer: The main components for a Microservice Architecture are:
• Containers, Clustering, and Orchestration
• IaC [Infrastructure as Code Conception]
• Cloud Infrastructure
• API Gateway
• Enterprise Service Bus
• Service Delivery
13. What is the difference between Memcached and Redis?
Redis Memcached
• Redis also does cache information • Memcached only cache
but has got additional features like information.
persistence and replication • Memcached supports the
• Redis does not support the functionality of LRU (least recently
functionality of LRU (least recently used) eviction of values
used) eviction of values • In Memcached when they
• In Redis you can set a time overflow memory, the one you have not
out on everything when memory is full, used recently (LRU- least recently
it will look at three random keys and used) will get deleted
deletes the one which is closest to expiry • Memcached supports
• Redis does not support CAS (Check and Set)
CAS ( Check and Set). It is useful for • In Memcached, you have
maintaining cache consistency to serialize the objects or arrays in order
• Redis has got stronger data to save them and to read them back you
structures; it can handle strings, binary have to un-serialize them.
safe strings, list of binary safe strings, • Memcached had a
sorted lists, etc. maximum of 250 bytes length
• Redis had a maximum of • Memcached is a multi-
2GB key length threaded
• Redis is single threaded

14. What is the difference between @RestController and @Controller in Spring


Boot?
@controller @RestController
Controller is a common annotation that Rest controller is a Springspecial
is used to mark a class as a spring MVC controller used in Restful web services
controller. and the wrapped within the @controller
and @Responsebody
SQL
1. Sự khác biệt giữ where và Having ?
2. What is the difference between DELETE and TRUNCATE statements?
DELETE TRUNCATE
Delete command is used to delete a row Truncate is used to delete all the rows
in a table. from a table.
You can rollback data after using delete You cannot rollback data.
statement.
It is a DML command. It is a DDL command.
It is slower than truncate statement. It is faster

3. What are MySQL “Views”?


In MySQL, a view consists of a set of rows that is returned if a particular query is
executed. This is also known as a ‘virtual table’. Views make it easy to retrieve the way
of making the query available via an alias. The advantages of views are:
• Simplicity
• Security
• Maintainability
4. . What are MySQL Triggers?
A trigger is a task that executes in response to some predefined database event, such as
after a new row is added to a particular table. Specifically, this event involves inserting,
modifying, or deleting table data, and the task can occur either prior to or immediately
following any such event. Triggers have many purposes, including:
• Audit Trails
• Validation
• Referential integrity enforcement
5. How many Triggers are possible in MySQL?
There are six Triggers allowed to use in the MySQL database:
• Before Insert
• After Insert
• Before Update
• After Update
• Before Delete
• After Delete
6. How to join two tables in MySQL?
We can connect two or more tables in MySQL using the JOIN clause. MySQL allows
various types of JOIN clauses. These clauses connect multiple tables and return only
those records that match the same value and property in all tables. The following are the
four easy ways to join two or more tables in MySQL:
• Inner Join
• Left Join
• Right Join
• Cross Join

You might also like