Web Applications Quiz - Languages Java
Free practice quiz: Web Applications (Languages Java). 57 multiple-choice questions with answers and explanations. Play online, no sign-up needed.
Play all 57 questions freeSample questions
Which of the following is NOT a core technology used in building dynamic web applications?
- HTML
- CSS
- JavaScript
- SQL
Show answer
Answer: D. SQL
HTML, CSS, and JavaScript are fundamental client-side technologies for creating the structure, style, and interactivity of web pages. SQL (Structured Query Language) is primarily used for managing and querying relational databases, which are often used by web applications, but it's not a core client-side or server-side *programming* technology for building the application's logic itself.
What is the difference between a Servlet and a JSP?
- Servlets are for logic, JSPs are for presentation; JSPs compile into Servlets.
- Servlets handle client-side interactions, JSPs handle server-side logic.
- Servlets are used for database access, JSPs are used for rendering.
- There is no significant difference; they are interchangeable.
Show answer
Answer: A. Servlets are for logic, JSPs are for presentation; JSPs compile into Servlets.
Servlets are Java code that are good for handling business logic and request processing. JSPs are HTML-like documents with embedded Java code, designed for easier presentation of dynamic content. The JSP container typically translates and compiles JSPs into servlets.
What is the concept of 'stateless' in the context of RESTful web services?
- Each request from a client to the server must contain all the information necessary to understand and complete the request.
- The server maintains session state for all clients.
- The server can cache responses indefinitely.
- Clients can only make GET requests.
Show answer
Answer: A. Each request from a client to the server must contain all the information necessary to understand and complete the request.
In a stateless architecture, the server does not store any client context between requests. This improves scalability and reliability as any server can handle any request.
What is the difference between `RequestDispatcher.forward()` and `HttpServletResponse.sendRedirect()` in Java Servlets?
- forward() sends a new request, while sendRedirect() uses the same request.
- forward() transfers control to another resource within the same server (server-side) without the client's knowledge; sendRedirect() instructs the client's browser to make a new request to a different URL.
- forward() is used for GET requests, sendRedirect() is for POST requests.
- There is no practical difference; they are interchangeable.
Show answer
Answer: B. forward() transfers control to another resource within the same server (server-side) without the client's knowledge; sendRedirect() instructs the client's browser to make a new request to a different URL.
`forward()` is an internal server-side operation that keeps the original request. `sendRedirect()` involves a client-side round trip, sending a 302 status code to the browser, which then initiates a new request.
What is a common use case for Java Mail API?
- Sending emails from a web application.
- Handling HTTP requests.
- Managing user sessions.
- Performing database queries.
Show answer
Answer: A. Sending emails from a web application.
The Java Mail API provides a platform-independent, protocol-independent framework for sending and receiving emails, commonly used in web applications for notifications, account verification, etc.