_________ is a technique in Java to optimize memory usage by reusing objects.
- Garbage Collection
- Memory Optimization
- Object Pooling
- Singleton Pattern
Object Pooling is a technique in Java to optimize memory usage by reusing objects, thereby reducing the overhead of creating new objects.
How does Java's heap memory management differ from stack memory management?
- Both heap and stack memory are used interchangeably.
- Heap and stack memory are the same in Java.
- Heap memory is used for dynamic memory allocation, and objects are stored in the heap. Stack memory is used for static memory allocation, and method calls and local variables are stored in the stack.
- Stack memory is used for dynamic memory allocation, and objects are stored in the stack. Heap memory is used for static memory allocation, and method calls and local variables are stored in the heap.
In Java, heap memory is used for dynamic memory allocation, and objects are stored in the heap, while stack memory is used for static memory allocation, storing method calls and local variables.
What is a memory leak in the context of Java programming?
- A memory leak occurs when a program allocates memory but forgets to deallocate it, leading to a gradual reduction in available memory.
- A memory leak occurs when a program deallocates memory properly, ensuring optimal memory usage.
- Memory leaks are intentionally created to enhance program performance.
- Memory leaks only occur in languages other than Java.
A memory leak in Java programming happens when the program allocates memory but forgets to deallocate it, resulting in a gradual reduction in available memory.
Can session tracking be implemented using hidden form fields?
- Depends on the browser
- No
- Possible only in HTTPS
- Yes
Session tracking can be implemented using hidden form fields by including the session identifier in the form, allowing it to be sent back to the server with each form submission.
The ServletContext is shared across multiple servlets within a __________.
- request
- server
- session
- web application
The ServletContext is shared across multiple servlets within a web application.
What is URL rewriting in the context of session tracking?
- Appending a random string to the URL for session identification.
- Creating a new URL for each session.
- Hiding session information in the URL.
- Modifying the URL to include session information.
URL rewriting in session tracking involves modifying the URL to include session information. This enables the server to identify the client's session when processing subsequent requests.
Which HTTP header is commonly used to control cache behavior in web browsers?
- Cache-Control
- Content-Encoding
- Expires
- Last-Modified
The Cache-Control header is commonly used to control cache behavior in web browsers by specifying directives for caching mechanisms in both requests and responses.
The __________ and __________ are two major parts of JVM memory structure.
- Cache, Register
- Heap, Stack
- Queue, Linked List
- Stack, Heap
The Heap and Stack are two major parts of the JVM memory structure. The Heap is used for dynamic memory allocation, while the Stack is used for static memory allocation and method call management.
A servlet forwards a request to a JSP page for rendering the view. Which method does it use, and what happens to the URL in the browser?
- request.getRequestDispatcher().forward()
- request.sendRedirect()
- response.forward()
- response.sendRedirect()
The correct method for forwarding a request to a JSP page is request.getRequestDispatcher().forward(). The URL in the browser remains the same as the original request URL.
The __________ area in JVM memory is used to store per-class structures.
- Class
- Heap
- Method
- Stack
The Class area in JVM memory is used to store per-class structures, such as class metadata, constants, and static fields.