Interview Java Question
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.