42. Explain the expression language in JSP.
The expression language is used in JSP to simplify the accessibility of objects. It provides many objects that can be used directly like param, requestScope, sessionScope, applicationScope, request, session, etc.
43. What are implicit objects?
Implicit objects, also called pre-defined variables, are created by the JSP engine inside the service method so that it can be accessed directly without being declared explicitly.
44. Define a cookie. What are the differences between a session and a cookie?
A cookie is a small piece of information, which is sent to the browser by a web server. The browser stores the cookies for every web server in a local file. In a future request, the browser sends all stored cookies for that detailed web server.
The difference between cookies and sessions are:
- A session works regardless of the settings on the client browser. The client may have selected to disable cookies.
- Sessions and cookies also differ in storing the amount of information. The HTTP session is able to store any Java object, while a cookie can only store String objects.
45. What is HTTP Tunneling?
HTTP tunneling refers to encapsulating the private network data/information and transmitting it through a public network. Instead of sending data as a packet, tunneling encrypts the data and encapsulates it in a connection. This process allows the outside clients to collect all the data sent by the client-side Object Request Broker (ORB) that needs to be sent to the server-side ORB. HTTP tunneling masks other protocol requests as HTTP requests.
46. What is the function of the IOC container in spring?
The IOC container is responsible for:
- Creating an instance
- Configuring the instance
- Assembling the dependencies
47. What is lazy loading in hibernate?
Lazy loading is a kind of setting that decides whether to load the child entities along with the parent entities or not. When enabling this feature, the associated entities will be loaded only when they are requested directly. The default value of this setting is ‘true’ which stops the child entities from loading.
48. How can we fetch records using Spring JdbcTemplate?
We can fetch records from the database by the query method of JdbcTemplate. There are two interfaces to do this:
- ResultSetExtractor
- RowMapper
49. Which is the front controller class of Spring MVC?
The Dispatcher Servlet class works as the front controller in Spring MVC.
50. What are the states of an object in hibernate?
The states of an object in hibernate are:
- Transient: The objects that are just created having no primary key are in a transient state. Here the objects are associated with any session.
- Persistent: When the session of an object is just opened and its instance is just saved or retrieved, it is said to be in a persistent state.
- Detached: When the session of an object is closed, it is said to be in a detached state.
51. How to make an immutable class in hibernate?
If we mark a class as mutable=”false”, the class will be treated as an immutable class. The default value of mutable is “true”.
52. What is hash-collision in a HashTable? How is it handled in Java?
In HashTable, if two different keys have the same hash value, then it leads to hash-collision. A bucket of type linked list is used to hold the different keys of the same hash value.
53. Write a syntax to convert a given collection to a SynchronizedCollection.
The following will convert a given collection to a synchronized collection:
Collections.synchronizedCollection(Collection collectionObj)
54. Write a code to make the Collections read-only.
We can make the Collections read-only by using the following lines code:
General : Collections.unmodifiableCollection(Collection c)Collections.unmodifiableMap(Map m) Collections.unmodifiableList(List l) Collections.unmodifiableSet(Set s)
55. What is meant by binding in RMI?
Binding is the process of associating or registering a name for a remote object, which can be used as a further, in order to look up that remote object. A remote object can be associated with a name using the bind/rebind methods of the Naming class.
56. What are latest features introduced in Java 8?
The below features are introduced in Java 8:
- Lambda Expressions
- Interface Default and Static Methods
- Method Reference
- Parameters Name
- Optional Streams
- Concurrency
57. Name a few Java 8 annotations.
@Functional Interface annotation: It was introduced in Java SE 8, which indicates that the type declaration is intended to be a functional interface as defined by the Java language specification.
@Repeatable annotation: Introduced in Java SE 8, @Repeatable annotation indicates that the marked annotation can be applied many times to the same declaration or type use.
58. Distinguish between a predicate and a function.
A predicate takes one argument and returns a Boolean value.
A function takes one argument and returns an object. Both are useful for evaluating lambda expressions.
59. Write a code to sort a list of strings using Java 8 lambda expression.
. private void sortUsingJava8(List names){ Collections.sort(names, (p1, p2) -> p1.compareTo(p2)); }
60. What is Nashorn in Java 8?
With Java 8, Nashorn, a much-improved JavaScript engine, is introduced and it replaced the existing Rhino. It provides 2–10 times better performance, as it directly compiles the code in memory and passes the bytecode to JVM. Although, Nashorn uses the invoke dynamic feature, introduced in Java 7, to improve performance.
61. Define a StringJoiner and write a sample code.
StringJoiner is a util method to construct a string with the desired delimiter.
Sample CodeStringJoiner strJoiner = new StringJoiner("."); strJoiner.add("AAA").add("BBB"); System.out.println(strJoiner); OutPut: AAA.BBB
62. Can you execute the JavaScript code from Java 8 code base?
Yes! We can execute the JavaScript code from Java 8 code base by using ScriptEngineManager. We call JavaScript code and interpret it in Java.
63. What is the use of batch processing in JDBC?
Batch processing is a technique that is used to group a set of related SQL queries and execute them in order. This is done to avoid the execution of a single query at a time.
Making use of batch processing ensures that the queries execute faster, thereby maintaining the high efficiency and overall speed of execution.
64. What are the types of statements supported by JDBC?
There are three types of statements supported by JDBC as shown below:
- Statement: Used to execute static queries and for general access to the database
- CallableStatement: Provides access to stored procedures and runtime parameters
- PreparedStatement: Provides input parameters to queries while they are executing
65. What is a collection in Java?
A collection is a framework that is used to store and manipulate a container of objects in Java.
Collections can be used for performing a variety of operations such as:
- Search
- Sort
- Manipulate
- Delete
Below is the chart that represents the hierarchy of collections in Java:
66. What is the meaning of constructor overloading in Java?
Constructor overloading is a technique that is popular among programmers who have a requirement of adding multiple constructors to a single class with a different parameter list.
The following denotes an example of constructor overloading:
class Hello { int i; public Hello(int x) { i=k; } public Hello(int x, int y) { /* Set of Instruction */ } }
'IT Job > 기술면접질문' 카테고리의 다른 글
[MicroService] Interview Question (0) | 2021.01.29 |
---|---|
[Docker] Docker Interview 70 Questions (0) | 2021.01.12 |
[JAVA] Easy Interview question (0) | 2021.01.12 |