WT Viva Questions
WT Viva Questions
1. What is a Servlet?
Answer: A Servlet is a Java program that extends the capabilities of servers and
responds to requests from clients. It is a server-side technology used for developing
dynamic web applications.
Answer: Unlike CGI scripts, Servlets run in the address space of the web server,
providing better performance. Servlets are platform-independent because they are
written in Java, and they reuse the existing process, unlike CGI, which creates a
new process for each request.
Answer: The init() method is called when a Servlet is first loaded into memory. It
is used for one-time initialization tasks, such as loading resources or establishing
database connections. It is called by the servlet container.
Answer: Both doGet() and doPost() are methods used to handle HTTP requests.
doGet() is used for handling HTTP GET requests, typically used for data
retrieval.
doPost() is used for handling HTTP POST requests, which are used for
submitting data.
Answer: A Servlet can communicate with a JSP page by setting attributes in the
request or session scope. The Servlet can use the RequestDispatcher to forward
the request to the JSP page.
Answer: The destroy() method is called when a Servlet is unloaded from the
server. It is used for performing cleanup tasks, such as closing database
connections or releasing resources.
Answer:
sendRedirect() sends a response to the client with a new URL, and the
client's browser makes a new request to that URL.
forward() forwards the request from one Servlet to another Servlet or JSP
page on the server without involving the client's browser.
Answer: Exceptions in a Servlet can be handled using the try, catch, and finally
blocks. Alternatively, the error-page element in the deployment descriptor
(web.xml) can be used to specify an error page for handling exceptions.
These questions cover fundamental concepts related to Servlets. Adjust the level of
complexity based on the depth of Servlet knowledge expected in your viva
examination
11. Explain about Servlet API?
1. What is JSP?
Answer: JSP stands for JavaServer Pages. It is a technology used for developing
web pages that support dynamic content, and it allows Java code to be embedded
into HTML pages.
Answer: Servlets are Java programs that execute on the server-side to handle
requests, while JSP is a technology that mixes HTML and Java code to create
dynamic web content. JSPs are easier to write and maintain than servlets for web
page development.
Answer: When a JSP page is requested for the first time, the JSP engine translates
it into a servlet. This servlet is then compiled, loaded, and executed by the servlet
container.
Answer: Directives in JSP provide global information about an entire page and are
defined between <%@ and %> tags. Examples include page directives for setting
attributes like contentType, import, session, and buffer.
Answer:
Answer: A taglib (tag library) in JSP is a collection of custom tags that extend the
functionality of JSP. Taglibs are defined in the web.xml file and enable the use of
custom tags in JSP pages.
Answer: JSP expressions (<%= %>) are used to insert dynamic content into the
HTML page. The expression is evaluated, converted to a string, and inserted into
the place where the expression appears in the HTML.
Answer: JSP declarations (<%! %>) are used to declare variables and methods
that can be used later in the JSP page. Declarations are placed outside the HTML
tags.
Answer:
1. What is JavaScript?
Answer: Despite the similar names, JavaScript and Java are different:
Answer: Variables in JavaScript are declared using the var, let, or const keyword.
Answer:
Answer: The this keyword in JavaScript refers to the current execution context. Its
value depends on how a function is called:
Answer: You can add an event listener using the addEventListener method. For
example:
javascriptCopy code
document . getElementById ( "myButton" ). addEventListener ( "click" , function () {
alert ( "Button clicked!" ); });
These questions cover various aspects of JavaScript. Adjust the complexity based
on the level of understanding expected in your viva examination.
12.javascript methods
PHP
1. What is PHP?
Answer: A PHP script is initiated with <?php and terminated with ?>. For
example:
Answer: Both echo and print are used to output data, but echo can take multiple
parameters, while print can only take one parameter. echo is slightly faster, and it
does not return a value, whereas print returns 1, so it can be used in expressions.
Answer:
== is the equality operator, which checks if the values are equal after type
coercion.
=== is the identical operator, which checks if the values are equal and of the
same type.
Answer: The include and require statements are used to include one PHP file into
another.
$_GET is used to collect form data sent in the URL (as query parameters).
$_POST is used to collect form data sent with the HTTP POST method.
Answer: Sessions in PHP are used to store user information across multiple pages.
The session_start() function initiates a session, and $_SESSION is used to store
and retrieve session variables.
Answer: The header() function is used to send raw HTTP headers. It is often used
for redirecting users to another page, setting cookies, or specifying the content type
of the page.
Answer:
These questions cover various aspects of PHP. Adjust the complexity based on the
level of understanding expected in your viva examination.
XML
1. What is XML?
Answer: The XML prolog is the first line in an XML document and typically
includes the XML version and encoding information. For example:
Answer:
Elements: Represent the structure and hierarchy of data. They can contain
text, other elements, or both.
Attributes: Provide additional information about an element. They are
always included in the start tag and follow the name-value pair format.
Answer:
Well-formed XML: Follows the basic syntax rules of XML. It has a prolog,
properly nested elements, and correct use of attributes.
Valid XML: Not only well-formed but also adheres to a Document Type
Definition (DTD) or XML Schema Definition (XSD) that defines the
document's structure and data types.
Answer:
Answer: XML comments are written using the <!-- ... --> syntax. For example:
These questions cover key aspects of XML. Adjust the complexity based on the
level of understanding expected in your viva examination.
Header tags
Marque tags
List tags
Table tags
row span,
col span
Anchor tag
CSS
Internal CSS
External CSS