Nothing Special   »   [go: up one dir, main page]

Questions

Download as xlsx, pdf, or txt
Download as xlsx, pdf, or txt
You are on page 1of 252

QuestionText Choice1

Carefully read the question and answer accordingly.


Which two of the following statements correctly store an object
associated with a name at a place where all the servlets/JSPs of the
same webapp participating in a session can use it?
(Assume that request, response, name, value etc. are references to
objects of appropriate types.)
1.response.setAttribute(name, value)
2.getServletContext().setAttribute(name, value)
3.request.setAttribute(name, value)
4.request.getSession().setAttribute(name, value)
5.request.setParameter(name, value) 1&2

Carefully read the question and answer accordingly.


Consider the following servlet code segment:
HttpSession session = request.getSession(true);
session.setAttribute(“name”, “Cognizant”);
session.invalidate(0);
if (session.isNew())
{ System.out.println(session.getAttribute(“name”);
} else { System.out.println(session.isNew());
}
What is the output of the above code segment ? Displays “Cognizant” always
Carefully read the question and answer accordingly.
Consider the following code for an HTML form.
<form action=”/servlet/Login”>
<input type=”text” name=”username” value=”enter username”/>
<input type=”submit” name=”sbbutton” value=”signin!..”/>
</form>
Which of the following happens upon pressing the submit button in the
above form?
1.A request is sent with the HTTP method GET.
2.A request is sent with the HTTP method POST.
3.The parameter username is the only parameter passed to the web
server in the request.
4.The parameters username and sbbutton are passed to the web
server in the request URL. 1&2

Carefully read the question and answer accordingly.


Consider the following code snippet:
ServletContext sc = this.getServletContext();
RequestDispatcher dis = sc.getRequestDispatcher("/menu.jsp");
if (dis != null){
dis.include(request, response);
}
PrintWriter out = response.getWriter();
out.print("Output after menu.jsp"); Compilation and output of
Which one of the following will be the correct outcome when the the contents of menu.jsp
above lines are executed? only

Carefully read the question and answer accordingly.


Which of the following options can be used by the controller to destroy By using the invalidate()
a session of a web application immediately? method

Carefully read the question and answer accordingly.


Given an HttpServletRequest request:
22. String id = request.getParameter("jsessionid");
23. // insert code here
24. String name = (String) session.getAttribute("name");
Which statement can be placed at line 23 to retrieve an existing HttpSession session =
HttpSession object? request.getSession(id);
Carefully read the question and answer accordingly.
Consider the following deployment descriptor(web.xml)file:
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
Then, in the Servlet program code setMaxInactiveInterval(600)
(seconds) for the session object is invoked. After how long would
session expire? Select one answer from the following. 30 minutes

Carefully read the question and answer accordingly.


Which of the following is the deployment descriptor file of a web
application? Assuming that the name of the Web application is
BankApp. BankApp.xml

Carefully read the question and answer accordingly.


Martin has created a Web application in which a servlet stores a
JDBC URL as an attribute of the session object to access a database. HttpSession session =
He wants other servlets of the application to retrieve the URL attribute request.getSession(); String
from the session object to access the database. Which of the url
following code snippets can Martin use to retrieve the URL from the =(String)session.getAttribut
session object? e("URL");

Carefully read the question and answer accordingly.


Consider the following statements:
Statement A: GenericServlet is an abstract class
Statement B: GenericServlet internally implements Servlet interface Statement A is true and
Which of the following is true about these statements? statement B is true.

Carefully read the question and answer accordingly.


You being a software developer needs to develop a web application
for your organization. You decided to use servlets to create the web
application. While you are creating the servlet you feel the need to
write the code for the initialization of the servlet. This is needed to
initialize the servlet with the required data after the servlet instance By overriding the service
has been created. How will you perform this task? method in the servlet class.
Carefully read the question and answer accordingly.
Manoj has created the Hello servlet that displays Welcome in the
browser window. The code of the servlet is:
package myworld;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class hello extends HttpServlet
{
protected void doGet(HttpServletRequest request
HttpServletResponse response) throws ServletException IOException

{
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>My Servlet</title>");
out.println("</head>");
out.println("<body>"); <servlet> <servlet-
out.println("<h>WELCOME</h>"); name>hello</servlet-name>
out.println("</body>"); <servlet-
out.println("</html>"); class>hello</servlet-class>
out.close(); </servlet> <servlet-
} mapping> <servlet-
} name>hello</servlet-name>
Which of the following code snippets correctly defines the deployment <url-pattern>/hello</url-
descriptor for the preceding servlet? pattern> </servlet-mapping>

Carefully read the question and answer accordingly. <HTML> <BODY> <FORM
Which of the following codes will allow the user to load the servlet ACTION=http://localhost:80
using form. The form should first display submit button and when the 80/servlet/myservlet
user clicks on submit button it should load the servlet called METHOD=GET> </FORM>
myservlet? </BODY> </HTML>

RequestDispatcher
dispatcher =
request.getRequestDispatc
her("Servlet2");
Carefully read the question and answer accordingly. dispatcher.forward(req,
Select the code to chain a servlet with another servlet resp);
Carefully read the question and answer accordingly.
Mahesh has observed that some users are able to directly access the
content files stored in the Web application from the Web browser.
Which of the following options should Mahesh use to prevent the By storing the content files
users from directly accessing the content files? under the dist directory

Carefully read the question and answer accordingly.


Which of the following is an interface that gets data from the client and
sends it to the servlet? ServletRequest

Carefully read the question and answer accordingly.


Whenever a request goes from the client to the server some
additional information other than the request is also passed to the
server. This additional information is in the form of a ____________. footer

Firewall server mainly


Carefully read the question and answer accordingly. focusses on network
Which of the following is / are true about a firewall server? security within a LAN

Carefully read the question and answer accordingly.


HTTP cannot save state information between one request and other TRUE

Carefully read the question and answer accordingly.


If the application is associated with JDK, it will lead to lighter memory
footprint compared associating the application to JRE TRUE

Carefully read the question and answer accordingly.


Consider the following statements:
Statement A: Modules of Java code run in a server application is
called Applet
Statement B: Modules of Java code run at client side is called Servlet Statement A is true and
Which of the following is true about these statements? statement B is true.

Carefully read the question and answer accordingly.


Which method can be used to submit form data that should not be
exposed for viewing? PUT
Carefully read the question and answer accordingly. Servlets are Platform
Which of the following is NOT TRUE for the servlet? Independent.

Carefully read the question and answer accordingly.


While architecting a system, if "minimum down time" is the primary
expected behavior of the system, the system architecture should be
based on ------------------- Firewall

Carefully read the question and answer accordingly.


Consider the following statements:
Statement A: A resource is passive when it does not have any
processing of its own.
Statement B: The content of a passive resource does not change. Statement A is true and
Which of the following is true about these statements? statement B is true.

Layered architecture
separates the functionalities
Carefully read the question and answer accordingly. to individual layers, thereby
Which of the following is / are true about the layered architecture improving maintainability &
style? reusability

Carefully read the question and answer accordingly.


HttpServletRequest is a sub interface of ____________. HttpRequest

Carefully read the question and answer accordingly.


HTTP protocol allows asynchronous transactions between a client
and server TRUE

Carefully read the question and answer accordingly.


The proposed web application need to access two databases, for
performing the business operations. Which of the API in J2EE
package will support to achieve this functionality? JNDI

Carefully read the question and answer accordingly.


A server will serve a request. Application Server handles request that
needs dynamic content, whereas a web server will handle the request
for static content. TRUE
These are specialized Web
Carefully read the question and answer accordingly. servers, which support
Which of the following is applicable to Servlet Containers? servlet execution

Carefully read the question and answer accordingly. provides security


Which of the following can be considered as role(s) of a deployment information of the
descriptor in a .war or .ear modules? application

Carefully read the question and answer accordingly.


Which of the following methods are not implemented by the
RequestDispatcher interface?
1.redirect()
2.forward()
3.include()
4.dispatch() 1&2

Carefully read the question and answer accordingly.


If 1000 users are accessing SampleServlet how many actual object of
servlets exist in web container? 1000

Carefully read the question and answer accordingly.


In "n-tier" architecture style, the layers of a web application reside
over multiple physical computers. TRUE

Carefully read the question and answer accordingly.


Which of the following tag is NOT a part of the web.xml file? <servlet>

Carefully read the question and answer accordingly.


A web application contains images to be displayed across the UI
screens. In a typical production environment, where these images will
be deployed? Application Server

Carefully read the question and answer accordingly.


For every HTTP request, static contents will be served by a web
server, whereas if dynamic content is requested, web server forwards
the request to application server. TRUE
Carefully read the question and answer accordingly.
Always the enterprise archive (EAR) files will be deployed in a web
container TRUE

Carefully read the question and answer accordingly.


The method getWriter() of HttpServletResponse returns an object of
type ____________. HttpServletRequest

Carefully read the question and answer accordingly.


Which of the following Java EE containers manages the execution of
enterprise beans for Java EE applications? EJB container

Carefully read the question and answer accordingly.


A proxy server will allow to cache web pages in your computer TRUE

Carefully read the question and answer accordingly.


Which are lifecycle methods of Servlet Interface?
1.public abstract void init(ServletConfig config)
2.public abstract void service(ServletRequest req, ServletResponse
res)
3.public abstract void destroy(ServletContext)
4.public abstract void destroy() 1&2&3

Carefully read the question and answer accordingly.


Websphere Application server is a open source server TRUE

Carefully read the question and answer accordingly. web application provides
Which of the following is / are true about web applications? cross platform compatibility

Carefully read the question and answer accordingly.


If the proposed system to be developed to handle concurrent user
requests, with reduced turn-around time & resource usage, then the
architecture should employ --------------- Firewall

Carefully read the question and answer accordingly.


URL and URN are one and the same TRUE

Carefully read the question and answer accordingly.


Which of the following code line will destroy a session? session.isAlive = false;
Carefully read the question and answer accordingly.
Which of the following techniques are used to track session? URL rewriting

Carefully read the question and answer accordingly.


Mark is developing a web based application. The home page is a
servlet that accepts the user name and password. Mark does not want
the user to enter the username every time he logs into the website.
He wants to find a way to store the value on the user's machine.
Which method should he use so that the value gets stored on the
user's machine? getCookie()

Carefully read the question and answer accordingly.


HTTP is stateful protocol which maintains clients state automatically.
State True or False. FALSE

Carefully read the question and answer accordingly.


Which of the following method of the HttpServletRequest object is
used to get the clients session information in the HttpSession object? putValue()

Session timeout
declarations made in the
Carefully read the question and answer accordingly. DD(web.xml) can specify
Which statements about session timeouts are true? time in seconds.

Carefully read the question and answer accordingly.


A container does not initialize the servlets as soon as it starts up, it
initializes a servlet when it receives a request for that servlet first time.
This is called lazy loading.State True or False. TRUE

Carefully read the question and answer accordingly.


Which method of HttpSession interface is used for specifying the
length of inactive interval for a session object? setMaxInterval()

Carefully read the question and answer accordingly.


Which of the following listeners are invoked when a session is
created? HttpSessionBindingListener

Carefully read the question and answer accordingly.


Given that URL-rewriting must be used for session management,
identify the query string attribute used when URL-rewriting. sessionid
Carefully read the question and answer accordingly.
Which two of the following are true statements about sessions?
1.Sessions are destroyed only after a predefined period of inactivity
2.Sessions can span web applications
3.Sessions can be cloned across JVMs
4.You can use the deployment descriptor to cause sessions to expire
after a set number of requests
5.Sessions can be set to never time out 1&2

Carefully read the question and answer accordingly.


How can an existing session in servlet can be destroyed ?
1.programmatically using session.invalidate()
2.by calling session.service() method
3.by closing the browser
4.when the server itself is shut down 1&2

Carefully read the question and answer accordingly.


Servlet A receives a request that it forwards to servlet B within
another web application in the same web container. Servlet A needs
to share data with servlet B and that data must not be visible to other
servlets in A's web application. In which object can the data that A
shares with B be stored? HttpSession

public void
doGet(HttpServletRequest
req, HttpServletResponse
res) throws
ServletException,
IOException { HttpSession
Carefully read the question and answer accordingly. session = req.getSession();
Choose the valid option for creating session object and to add a session.setAttribute("BookI
attribute "BOOKID" into session object. D","Core Java"); }

Carefully read the question and answer accordingly.


How do you create a session? request.getSession()

Carefully read the question and answer accordingly.


In which of these following getAttibute()  and setAttribute() method
has defined?
1.HttpSession
2.ServletRequest
3.ServletResponse
4.HttpListener 1&3
Carefully read the question and answer accordingly.
Which of the following Listener can get context init parameter and run ServletContextAttributeListe
some code before rest of the application can service a client? ner

Carefully read the question and answer accordingly.


If you want to know when a request attribute has been
removed,added or replaced, then which listener is the appropriate
one? ServletRequestListener

Carefully read the question and answer accordingly.


Which of the following Listener is used to track number of active
sessions or users? ServletRequestListener

Carefully read the question and answer accordingly.


Which one is required as a sub-element of listener tag  in Deployment
Descriptor? <listener-type>

Carefully read the question and answer accordingly.


Sam is writing a web application program. He has implemented
ServletContextListener interface in his web application program.
Which method of ServletContextListener interface he should use to
perform startup activities for web application? init()

Carefully read the question and answer accordingly.


How will you retrieve the first value of request parameter “fname”?
1.${param.fname}
2.${requestParams.fname}
3.${requestScope.fname}
4.${paramValues.fname[0]} 1&3

Carefully read the question and answer accordingly.


How will you access a servlet context initialization parameter named
“company-name”? ${init.company-name}

Carefully read the question and answer accordingly.


Which of following are EL implicit objects?
1.pageContext
2.parameter
3.parameterValues
4.header
5.session 1&4

Carefully read the question and answer accordingly.


What is the syntax of Expression Language in a JSP page? ${expr}
Carefully read the question and answer accordingly.
Predict output of Expression Language ${7*k} if k is null: 0

Carefully read the question and answer accordingly.


Expression Language treats null values as “zero” In arithmetic
operations.State True or False. TRUE

Carefully read the question and answer accordingly.


Consider the following servlet code segment:
Map map = new HashMap();
map.put(“a”, “1”);
map.put(“b”, “2”);
map.put(“c”, “3”);
map.put(“d”, “4”);
request.setAttribute(“map”, map);
String[] names = {“a”, “b”, “c”, “d”};
request.setAttribute(“names” , names);
What does ${map[names[0]]} return? a

Carefully read the question and answer accordingly.


<%
List list=new ArrayList();
list.add("a");
list.add("2");
list.add("c");
request.setAttribute("list",list);
request.setAttribute("number","1");
%>
Based on the above code segment, which of the following will
display "c"?
1.${list[2]}
2.${list.2}
3.${list[number+1]}
4.${list.3} 1&3

Carefully read the question and answer accordingly.


Which of the following EL implicit objects is not a Map? requestScope

Carefully read the question and answer accordingly.


Code to get the value of “address” request parameter is: ${param.address}

Carefully read the question and answer accordingly.


Choose valid expression language statement for accessing textfield
elements whose name is userid. #{param.userid}
Carefully read the question and answer accordingly.
Consider the code segment given below:
List list = new ArrayList();
list.add(“1”);
list.add(“2”);
list.add(“3”);
list.add(“4”);
request.setAttribute(“list”, list);
String[] names = {“a”, “b”, “c”, “d”, “e”};
What will ${names[list[0] + 1]} display? a,b

Carefully read the question and answer accordingly.


Select correct options with respect to Expression Language (EL) used
in JSP
1.The purpose of EL is to make a JSP script free
2.EL is a simple and powerful replacement of Standard Actions
3.EL is enabled in a JSP by default
4.EL stands for Extended Language 1&2

Carefully read the question and answer accordingly.


You have a map named “carMap” with a key named “Ford”. Select
correct EL syntaxes to print the value of this key.
1.${carMap.Ford}
2.${carMap.[Ford]}
3.${carMap[“Ford”]}
4.${carMap[Ford]} 1&2

Carefully read the question and answer accordingly.


Consider the following statements:
Statement A: A tag library descriptors an XML document that contains
information about a library as a whole and about each tag contained
in the library.
Statement B: TLDs are used by a Web container to validate the tags
used by JSP page development tools. Statement A is true and
Which of the following is true about these statements? statement B is true.
Carefully read the question and answer accordingly.
<?xml version="1.0" encoding="UTF-8"?>
<taglibxmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2eeweb-
jsptaglibrary_2_0.xsd" version="2.0">
<tlib-version>2.0</tlib-version>
<short-name>SimpleTagForLearning</short-name>
<uri>testuri</uri>
<tag>
<name>helloworld</name>
<tag-class>com.cts.MyTagHandler</tag-class>
<body-content>empty</body-content>
<attribute>
<name>attrb</name> <%@ taglib prefix="pre"
<required>true</required> uri="testuri" %> <html>
<rtexprvalue>true</rtexprvalue> <head> <title>Demo on
</attribute> helloworldCustom tag</title>
</tag> </head> <h1>
</taglib> <pre:helloworld/> </h1>
For above mentioned .tld select correct tag usage option in JSP page. </html>

Carefully read the question and answer accordingly.


Consider the following statements:
Statement A: When tags are implemented with tag handlers written in
Java, each tag in the library must be declared in the TLD with a tag
element.
Statement B: The tag element contains the tag name, the class of its
tag handler, information on the tag's attributes, and information on the
variables created by the tag. Statement A is true and
Which of the following is true about these statements? statement B is true.

Carefully read the question and answer accordingly.


TagSupport and BodyTagSupport classes are present in which
package? java.servlet.jsp.tagext

Carefully read the question and answer accordingly.


What is the output of the current code segment ?
<c:forTokens items=“a,b,c,d,e” delims=“,” begin=“0” end=“4” step=“2”
var=“alphabet”>
<c:out value=“${alphabet}”/>
</c:forTokens> a,c,e
Carefully read the question and answer accordingly. <a href='<c:url
Which JSTL code snippet can be used to perform URL rewriting? url="cognizant.jsp"/>'/>

Carefully read the question and answer accordingly.


Using prefix c to represent the JSTL library, which of the following
produces the same result as <%= var %>? <c:var out=${var}>

Carefully read the question and answer accordingly.


Which standard tag you choose to implement the switch functionality
using JSTL? <c:forEach>

Carefully read the question and answer accordingly.


Which attribute of <c:if> specifies the conditional expression? cond

Carefully read the question and answer accordingly.


Which of following are standard JSTL?
1.http://java.sun.com/jstl/xml/fmt
2.http://java.sun.com/jstl/core/fmt
3.http://java.sun.com/jstl/xml
4.http://java.sun.com/jstl/sql
5.http://java.sun.com/jstl/core 1&2&3

Carefully read the question and answer accordingly.


Consider the usage of JSTL forEach tag in the following code
snippet:
<font color='green'>
<ul>
<c:foreach flag=errmsg items="${errorMsgs}">
<li>$errmsg</li> <font color='green'> <ul>
</c:forEach> <c:forEach flag=errmsg
</ul> items="${errorMsgs}">
</font> <li>$errmsg</li>
The code snippet contains some errors. Predict the correct code. </c:forEach> </ul> </font>

Carefully read the question and answer accordingly.


If you would like the JSP container to first try to find the
“myBeanAttribute” attribute in the request scope. If it’s not existing
then should create the instance of “MyBean” and then assign it to the <jsp:useBean
“myBeanAttribute “ id variable in JSP and sets it as an attribute to the id="myBeanAttribute"
request scope. class=”com.cts.MyBean"
Which of the given option will help you to attain this? scope="request" />
Carefully read the question and answer accordingly.
Smith is developing an application using Java Server Pages. The
name of the component that he has It will iterate over the current
created is "Emp". he has included the following statement in her ServletRequest parameters
application: setting each matched
<jsp:setProperty name="Emp" property=* /> property to the value of the
What would be the result of the above code? matching parameter

Carefully read the question and answer accordingly.


Consider the following code snippet:
<jsp:forward page="relativeURLspec"/>
Which of the following statements is true about the execution status of The execution of the current
the page where this statement has been written? page continues.

<jsp:include page=”user-
Carefully read the question and answer accordingly. pref.jsp”> <jsp:param
In an web page how would you write the JSP standard action code to name=”userPref” value=”$
import a JSP segment that generates user preference specific {user.preference}” />
content? </jsp:include>

Carefully read the question and answer accordingly.


Given a servlet that stores an Account bean in the session scope with
the following code snippet:
public void doPost(HttpServletRequest req, HttpServletResponse
resp) {
HttpSession session = req.getSession();
com.cts.Account acc= new com.cts.Account();
emp.setAccountNumber(req.getParameter(“acc_num”));
session.setAttribute(“account”, acc);
RequestDispatcher page = req.getRequestDispatcher(“index.jsp”);
page.forward(req, resp); <%=
} account.getAccountNumber
Which of these complete JSPs will print the account number? () %>
Carefully read the question and answer accordingly.
What is the effect of executing the following JSP statement, assuming
a class with name Employee exists in com.cts package.
<jsp:useBean id="employee" class="com.cts.Employee" The code does not compile
scope="session"/> as property attribute cannot
<jsp:setProperty name="employee" property="*"/> take * as a value.

Carefully read the question and answer accordingly.


Consider the following code snippet of JSP Bean: <jsp:useBean id="login"
<jsp:usebean identity="login" scope="Session" scope="Session"
class=s.beans.LoginBean> class="s.beans.LoginBean"
<%! > <%
login.setValue(request.getParameter("Loginid")); login.setValue(request.getP
login.setAddress(request.getParameter("address")); arameter("Loginid"));
%> login.setAddress(request.ge
<jsp:usebean> tParameter("address")); %>
However the preceding code contains errors. Predict the correct code. </jsp:useBean>

Carefully read the question and answer accordingly.


Lisa is a web developer she developing dynamic web application
using JSP. She want to include "Header.jsp" in all JSP page which
she have designed. Which of the following statement includes
Header.jsp file?
1.<jsp:include page=“Header.jsp”/>
2.<jsp:include file=“Header.jsp”/>
3.<%@include file=“Header.jsp”%>
4.<%@include page=“Header.jsp”%> 1&3
Carefully read the question and answer accordingly.
For the given Employee class
package com.cts;
public class Employee{
private String strEmpID="";
public String getEmpId() {
return this.strEmpID;
}
public void setEmpId(String strEmpID){
this.strEmpID=strEmpID;
}
}
We have the JSP file
<jsp:useBean id="employee" class="com.cts.Employee"
scope="request">
<property name="person" property="empId" value="<%=
request.getParameter("empId")%>" />
</jsp:useBean>
<html>
<body>
Employee Id: <jsp:getProperty
</body></html> name="employee"
Identify the JSP tag from the given options to print the employee id. property="strEmpID"/>

Carefully read the question and answer accordingly.


Your web application views all have the same header which includes
<title> tag in the <head> element of the rendered HTML. You have
decided to remove the redundant HTML code from your JSPs and put
into a single JSP called /WEB-INF/jsp/header.jsp. However, the title of <jsp:insert page='WEB-
each page is unique, so you have decided to use variable called INF/jsp/header.jsp'>
pageTitle to parameterize this in the header JSP like this: <jsp:param
<title> ${param.pageTitle}</title> name='pageTitle'
Which JSP code snippet you use in your main view JSPs to insert the value=”Welcome Page” />
header and pass the pageTitle variable? </jsp:include>

Carefully read the question and answer accordingly.


Identify the different values which a scope attribute of a page, request, session and
<jsp:useBean>action can set? application.
Carefully read the question and answer accordingly.
Lisa is a systems programmer at ABC Consultants. She has written <%
an application to accept student marks in the variable marks. If the if(Integer.parseInt(request.g
student has scored marks greater than 60. She needs to forward the etParameter("marks"))>=60)
control of the program to another file called as "Ex.jsp" else the { %> <jsp:forward
control should be forwarded to a file called as "Av.jsp". page="Ex.jsp" /> <% } else {
Which of the following code snippets should she use for checking this %> <jsp:forward
condition and forward control? page="Av.jsp" /> <% } %>

Carefully read the question and answer accordingly.


Identify the different actions which are generally used while integrating <jsp:useBean><jsp:setProp
JavaBeans with JSP? erty> and <jsp:getProperty>

Carefully read the question and answer accordingly.


Which attribute of the page directive indicates that the JSP engine
can handle more than one request at a time when its value is set to
true? IsThreadSafe

Carefully read the question and answer accordingly.


Sally has written the following code to access the Employee bean that
has already been created with the property called EmpNumber:
<html>
<body>
<jsp:useBean id="employee" scope="session" class="Employee" />
<b> The current count for the Employee bean is:</b> <
%employee.getEmpNumber()%>
</body>
</html>
The bean has the following code in the getEmpNumber method:
public int getEmpNumber()
{
EmpNumber++;
return this.EmpNumber;
} The value will be
Which of the following statements is true about the output of the incremented everytime the
above code when the page is loaded and reloaded? page is loaded.

Carefully read the question and answer accordingly.


Which of the following objects of JSP contain the servlet
configuration? config
Carefully read the question and answer accordingly.
Which of the following variable represents the uncaught throwable
object that resulted from a call to the error page in JSP? Application

Carefully read the question and answer accordingly.


Which object of JSP holds reference to javax.servlet.http.HttpSession
object? session

Carefully read the question and answer accordingly.


What will be the output of the following code snippet?
<% page language="java"%>
<html>
<head></head>
<body>
<%java.util.Date now=new java.util.Date(); %>
<H1><%= now.getHours() %>:<%=now.getMinutes()%>:<
%=now.getSeconds()%></H1>
</body> It will display the date as
</html> mm:dd:yy.

Carefully read the question and answer accordingly. Putting <scripting-invalid>


Scripting can be blocked in a jsp by: element in web.xml

Carefully read the question and answer accordingly.


Gen wants to create a new JSP page. Which element of JSP provide
global information about an entire JSP page? Scriptlet

Carefully read the question and answer accordingly.


Manisha is creating an application which makes use of Java Server
pages. Which of the following implicit object she should use to get a
reference to the JSPWriter? out

Carefully read the question and answer accordingly. Print something on the
The purpose of a JSP Expression tag is to: screen

Carefully read the question and answer accordingly.


A scriptlet contains Java code that is executed every time a JSP is
invoked.State True or False. TRUE

Carefully read the question and answer accordingly.


You are developing dynamic web application using JSP. Which
attribute of page directive specifies the list of classes imported in the
JSP file? import
<html> <%! String
message="hello world";
Carefully read the question and answer accordingly. String getMessage() { return
Gen has written a JSP code in which he is calling the getMessage() message; } %> Message for
function which is returning a value "hello world". You have to identify you:<%= getMessage() %>
which code should he use to get this? </html>

Carefully read the question and answer accordingly.


Which of the following is valid declaration in JSP using declaration <!% String name="Rocky"
tag? %>

Carefully read the question and answer accordingly.


Which of the following attributes of page directive are invalid? isELIgnored

Carefully read the question and answer accordingly.


A Web application developed for an institution requires insertion of a
header file comprising the logo and institution name. Identify the
correct JSP tag from the options given below to add the logo and <form method="post"
institution name to all the pages of the Web application. action="Header.html">

Carefully read the question and answer accordingly.


Consider you are developing web application which following code
snippet listed depicts that the JSP page is an errorpage? %@ page isErrorPage="true" %

Carefully read the question and answer accordingly.


Given the JSP code:
<% request.setAttribute("foo", "bar"); %>
and the Classic tag handler code:
5. public int doStartTag() throws JspException {
6. // insert code here
7. // return int
8. }
Assume there are no other "foo" attributes in the web application. String x = (String)
Which invocation on the pageContext object, inserted at line 6, pageContext.getAttribute("fo
assigns "bar" to the variable x? o");

Carefully read the question and answer accordingly.


Consider you are developing web application. Which of the following <%@ page
option is a valid in JSP for importing the package? import="java.util.*" %>
Carefully read the question and answer accordingly.
Consider you are creating a JSP page. You want to use the
classes of java.util package. Which statement will you use to
import the java.util package? %@ page import="java.util.*" %
A servlet configuration
object used by a servlet
container to pass
Carefully read the question and answer accordingly. information to a servlet
What is the use of ServletConfig interface? during initialization

Carefully read the question and answer accordingly.


Which method binds an object to a given attribute name in this void setAttribute(String
ServletContext interface? name, Object object)

Carefully read the question and answer accordingly.


Which of the following interface represents the Servlet Config for the
current Servlet? javax.servlet.ServletConfig

Carefully read the question and answer accordingly.


ServletConfig comes into picture _______. after init() runs

Carefully read the question and answer accordingly.


Which of the following tag is used to specify the initialization
parameters in the web.xml file? <init-param>

Carefully read the question and answer accordingly.


What is the return type of getAttribute() method of HttpServletRequest
? Object

Carefully read the question and answer accordingly.


Which method of ServletConfig interface returns a String containing
the value of the named initialization parameter, or null if the parameter getInitParameter(String
does not exist? name)
Carefully read the question and answer accordingly.
Which method removes the attribute with the given name from the void flushAttribute(String
ServletContext interface? name)

private void
_jspService(HttpServletReq
uest request,
HttpServletResponse
response)throws
Carefully read the question and answer accordingly. ServletException,
Which of the following is valid _jspService() method signature? java.io.IOException
Carefully read the question and answer accordingly.
If an error occurs while the JSP page is being compiled, the server will
return a Exception. Identify the type of the Exception ParseException

Carefully read the question and answer accordingly.


When a JSP is executed, out of the following, what is most likely to be
sent to the client? The source JSP file

Carefully read the question and answer accordingly.


_jspService() method cannot be overridden by the author. Say True or
False TRUE

Carefully read the question and answer accordingly.


Consider the following code with line number given below:
Line 4: <%! int a=6; %>
Line 5: <% int b=8; %>
Line 6: Result is <%= a*b; %>
Which of the following are true with respect to the above code
segment? Line 4 is invalid

Carefully read the question and answer accordingly.


JSP files stored in the WEB-INF directory cannot be seen directly from
a visiting web browser. Say True or False TRUE

Carefully read the question and answer accordingly.


During the JSP translation if the translator encounters a malformed
JSP element), the server will return Exception. Identify the type of the
Exception. ParseException

Carefully read the question and answer accordingly.


Which of the following methods can not be over-ridden ? jspInit()

Carefully read the question and answer accordingly.


JSP syntax errors are caught during which lifecycle event of JSP? Execution

Carefully read the question and answer accordingly.


Identify the life cycle method that is called to initialize the instantiated
servlet instance. jspInitialize()

Carefully read the question and answer accordingly.


_jspService() method is called only for the first time a request comes
to jsp during its lifecycle TRUE
Carefully read the question and answer accordingly.
Identify the location in which the translated JSP servlet code will be
stored WEB-INF

Carefully read the question and answer accordingly.


A Java Server Page (JSP) cannot be deployed in web server TRUE
Carefully read the question and answer accordingly.
Translation and Compilation of JSP happens during: Deployment

Carefully read the question and answer accordingly.


jspInit() method can be overridden by the author. Say True or False TRUE

JSP page is translated to a


servlet, servlet is loaded
into memory, code is
Carefully read the question and answer accordingly. compiled, instance is
Which of the following describes the jsp life cycle process best? created

Carefully read the question and answer accordingly.


Which protocol Servlets and JSP use to communicate with clients? HTTP

Carefully read the question and answer accordingly.


Identify the method in which all our scriptlets code will be placed jspInit()

Carefully read the question and answer accordingly.


While overriding the destroy method(life cycle method), we should
always handle the JasperExpception. Say true or false TRUE

Carefully read the question and answer accordingly.


Which of the following tag disables scriplets? <is-scripting-invalid>

Carefully read the question and answer accordingly.


In JSP request implicit object is of which type? HttpServletRequest

Carefully read the question and answer accordingly. Servlet lifecycle


Which of the following is NOT a Container feature? management

Carefully read the question and answer accordingly.


Consider the following statements:
Statement A: JSP page is a text-based document that contains two
types of text viz. Static template data & JSP elements
Statement B: JSP is used for presentation stuff and servlets are used Statement A is true and
for control and business logic stuff. statement B is true.
Carefully read the question and answer accordingly.
Identify the entry in web.xml that will instruct the container to compile
the JSP when the container starts rather than waiting for the first time. <load-on-startup>

Carefully read the question and answer accordingly.


Which statement is true about Java Server Pages?
1.Used to build dynamic web pages
2.Platform dependent
3.HTML files with special tags that contain java source code to
generates dynamic content 1&3

Carefully read the question and answer accordingly.


Identify the life cycle method that is called when a JSP is destroyed jspDestroyed()

Carefully read the question and answer accordingly.


Which of the following options represents the presentation logic to
provide the data of the model in the MVC design pattern? Model

Carefully read the question and answer accordingly.


<%! int a=6; %>
<% int a=5; %>
<% int b=3; %>
Result is <%= a*b %>
What is the result of the above code segment ? Compilation error

Carefully read the question and answer accordingly.


It is not necessary to implement your own jspInit or jspDestroy
methods as they are made available within the base class. Say True
or False. TRUE

Carefully read the question and answer accordingly. Servlets are written in the
What language is used to write servlets and JSP? Java language

Carefully read the question and answer accordingly.


Which method of jsp is equivalent to service method of servlet? _jspService()

Carefully read the question and answer accordingly.


JSP initialization method(life cycle method) is called immediately
before the servlet instance was created TRUE

Carefully read the question and answer accordingly.


WAR stands for Web ARchive
Translation &
compilation,Instantiation,
initialization,service destroy
Carefully read the question and answer accordingly. container manages this life
Which of the following describes JSP life cycle management? cycle

Carefully read the question and answer accordingly.


A JSP page services requests as a servlet. Say True or False TRUE

Carefully read the question and answer accordingly.


The container supplies a ServletConfig reference to the jspInit()
method. Say true or false TRUE

Carefully read the question and answer accordingly.


Which of the following have default value set to true? session

Carefully read the question and answer accordingly. The init method of the
During translation the scriptlet code is copied inside: generated servlet

Carefully read the question and answer accordingly.


Ronald has observed that his Web application has some HTML tags
or features that all the Web browsers do not support. If the client's
browser does not support the application may or may not run or may
generate undesired output in the Web browser of the client. Therefore
Ronald wants to identify the type of browser and other specific
information about the client that sends the request to the Web
application before invoking the servlet. Which of the following options
will help Ronald provide this functionality? By programming filters

Carefully read the question and answer accordingly.


Given a Filter class definition with this method:
21. public void doFilter(ServletRequest request,
22. ServletResponse response,
23. FilterChain chain)
24. throws ServletException, IOException {
25. // insert code here
26. }
Which code line should you insert at line 25 to properly invoke the
next filter in the chain, or the target servlet if chain.forward(request,
there are no more filters? response);
Carefully read the question and answer accordingly.
The child elements of <filter> elements are:
1.<display-name>
2.<init>
3.<config>
4.<context>
5.<filter-class> 1&2

Carefully read the question and answer accordingly.


You are developing a web application using Servlets. You have to use
filters so that the web container intercepts the incoming requests
before it is forwarded to the servlet. Which of the following method is
called for every request intercepted by the filter? init

Carefully read the question and answer accordingly.


Which of the following used by container to validate a custom tag in a
JSP page? web.xml

Carefully read the question and answer accordingly.


<pref:tag1>
<%= result %>
</pref:tag1>
Which of the following are valid for the <body-content> tag of tag1? JSP

Carefully read the question and answer accordingly.


How do you declare a tag library within a JSP page to use custom
tags? By using scriptlet.

Carefully read the question and answer accordingly.


Mention some of the important functions of Servlet Filter.
1.Security Checks
2.allowing all the users
3.Modifying the request or response 1&2

Carefully read the question and answer accordingly.


A filter configuration object used by a servlet container to pass
information to a filter during initialization.
State True or False. TRUE

Carefully read the question and answer accordingly.


Filters can create responses by themselves.
State True or False. FALSE
Carefully read the question and answer accordingly.
What will be the output for following code?
class Super
{
static void show()
{
System.out.println("super class show method");
}
static class StaticMethods
{
void show()
{
System.out.println("sub class show method");
}
}
public static void main(String[]args)
{
Super.show();
new Super.StaticMethods().show();
} super class show method
} sub class show method

Carefully read the question and answer accordingly.


When one method is overridden in sub class the access specifier of
the method in sub class should be equal as method in super class.
State True or False. FALSE

Carefully read the question and answer accordingly.


A class can be declared as _______ if you do not want the class to be
subclassed. Using
the __________keyword we can abstract a class from its
implementation protected ,interface

Carefully read the question and answer accordingly.


The constructor of a class must not have a return type. TRUE

Carefully read the question and answer accordingly. Constructors can be


Which of the following are true about constructors? overloaded

Carefully read the question and answer accordingly.


A field with default access specifier can be accessed out side the
package.
State True or False. FALSE

Carefully read the question and answer accordingly.


________ determines which member of a class can be used by other
classes. specifier
Carefully read the question and answer accordingly.
Which of the following statements are true about Method Overriding?
I: Signature must be same including return type
II: If the super class method is throwing the exception then overriding
method should throw the same Exception
III: Overriding can be done in same class
IV: Overriding should be done in two different classes with no relation
between the classes I

Carefully read the question and answer accordingly.


If display method in super class has a protected specifier then what
should be the specifier for the overriding display method in sub class? protected or default

Carefully read the question and answer accordingly.


What will be the output for following code?
class Super
{
int num=20;
public void display()
{
System.out.println("super class method");
}
}
public class ThisUse extends Super
{
int num;
public ThisUse(int num)
{
this.num=num;
}
public void display()
{
System.out.println("display method");
}
public void Show()
{
this.display();
display();
System.out.println(this.num);
System.out.println(num);
}
public static void main(String[]args)
{
ThisUse o=new ThisUse(10);
o.Show();
} super class method display
} method 20 20
Carefully read the question and answer accordingly.
What will be the output of following code?
class Super2
{
public void display()
{
System.out.println("super class display method");
}
public void exe()
{
System.out.println("super class exe method");
display();
}
}
public class InheritMethod extends Super2
{
public void display()
{

System.out.println("sub class display method");


}

public static void main(String [] args)


{

InheritMethod o=new InheritMethod();

o.exe();
}
super class exe method sub
} class display method

Carefully read the question and answer accordingly.


Which of the following method is used to initialize the instance
variable of a class. Class
If one class is having
protected method then the
method is available for
Carefully read the question and answer accordingly. subclass which is present in
Which of the following are true about protected access specifier? another package

Carefully read the question and answer accordingly.


What will be the output for following code?
public class Variables
{
public static void main(String[]args)
{
public int i=10;
System.out.println(i++);
}
} 10

Carefully read the question and answer accordingly.


Constructor of an class is executed each time when an object of that
class is created TRUE
Carefully read the question and answer accordingly.
Which of the following correctly fits for the definition 'holding instances
of other objects'? Aggregation

Carefully read the question and answer accordingly.


public abstract class Shape
{
private int x;
private int y;
public abstract void draw();
public void setAnchor(int x, int y)
{
this.x = x;
this.y = y;
}
}
Which two classes use the Shape class correctly?
1.public class Circle implements Shape {
private int radius;
}
2.public abstract class Circle extends Shape {
private int radius;
}
3.public class Circle extends Shape {
private int radius;
public void draw();
}
4.public class Circle extends Shape {
private int radius;
public void draw() {/* code here */}
} 1&2

Carefully read the question and answer accordingly.


State whether TRUE or FALSE.
If any method overrides one of it’s super class methods, we can
invoke the overridden method through the this keyword. TRUE
Carefully read the question and answer accordingly.
What will be the output for following code?
class super3{
int i=10;
public super3(int num){
i=num;
}
}
public class Inherite1 extends super3{
public Inherite1(int a){
super(a);
}
public void Exe(){
System.out.println(i);
}
public static void main(String[]args){
Inherite1 o=new Inherite1(50);
super3 s=new Inherite1(20);
System.out.println(s.i);
o.Exe();
}
} 10 50

Carefully read the question and answer accordingly.


State whether TRUE or FALSE.
An abstract class cannot contain non abstract methods TRUE

Carefully read the question and answer accordingly.


What is the outputof below code:
package p1;
class Parent {
public static void doWork() {
System.out.println("Parent");
}
}
class Child extends Parent {
public static void doWork() {
System.out.println("Child");
}
}
class Test {
public static void main(String[] args) {
Child.doWork();
}
} Child Parent
Carefully read the question and answer accordingly.
interface A
{
public abstract void aM1();
public abstract void aM2();
}
interface B extends A
{
public void bM1();
public void bM2();
}
public class Demo extends Object implements B
{
} public void aM1(){} public
In above scenario class Demo must override which methods? void aM2(){}

Carefully read the question and answer accordingly.


State whether TRUE or FALSE.
The below code will compile & provide desired output:
package p1;
interface Bounceable {
void bounce();
void setBounceFactor(int bf);
private class BusinessLogic
{
int var1;
float var2;
double result(int var1,float var2){
return var1*var2;
}
}
}
class Test {
public static void main(String[] args) {
System.out.println(new
Bounceable.BusinessLogic().result(12,12345.22F));
}
} TRUE

Carefully read the question and answer accordingly.


Choose the correct option.
Statement I: When an abstract class is sub classed, the subclass
should provide the implementation for all the abstract methods in its
parent class.
Statement II: If the subclass does not implement the abstract method
in its parent class, then the subclass must also be declared abstract. Statement I & II are TRUE
Carefully read the question and answer accordingly.
Choose the correct option.
Statement I: A subclass inherits all of the “public” and “protected”
members of its parent, no matter what package the subclass is in.
Statement II: If the subclass of any class is in the same package then
it inherits the default access members of the parent. Statement I & II are TRUE

Carefully read the question and answer accordingly.


State whether TRUE or FALSE.
The below code will compile & provide desired output:
package p1;
class Parent {
private int doWork(){
System.out.println("Do Work - Parent");
return 0;
}
}
class Child extends Parent {
public void doWork(){
System.out.println("Do Work - Child");
}
}
class Test{
public static void main(String[] args) {
new Child().doWork();
}
} TRUE

Carefully read the question and answer accordingly.


State whether TRUE or FALSE.
If any class has at least one abstract method you must declare it as
abstract class TRUE

Carefully read the question and answer accordingly.


public interface Status
{
/* insert code here */ int MY_VALUE = 10;
}
Which are valid on commented line?
1.final
2.static
3.native
4.public 1&2
Carefully read the question and answer accordingly.
Choose the correct option.
Statement I: When all methods in a class are abstract the class can
be declared as an interface.
Choose the correct option.
Statement II: An interface defines a contract for classes to implement
the behavior. Statement I & II are TRUE

Carefully read the question and answer accordingly.


abstract class Vehicle
{
public int speed()
{
return 0;
}
}
class Car extends Vehicle
{
public int speed()
{
return 60;
}
}
class RaceCar extends Car
{
public int speed()
{
return 120;
}
}
public class Demo
{
public static void main(String [] args)
{
RaceCar racer = new RaceCar();
Car car = new RaceCar();
Vehicle vehicle = new RaceCar();
System.out.println(racer.speed() + ", " + car.speed()+", " +
vehicle.speed());
}
}
What is the result? 0, 0, 0
Carefully read the question and answer accordingly.
What will be the output for following code
public class
MethodOverloading {
int m=10,n;
public void div(int a) throws Exception{
n=m/a;
System.out.println(n);
}
public void div(int a,int b) {
n=a/b;
}
public static void main(String[]args) throws Exception{
MethodOverloading o=new MethodOverloading();
o.div(0);
o.div(10,2); It will print
} ArithmeticException and
} prints 5

Carefully read the question and answer accordingly.


State whether TRUE or FALSE.
The below code will compile & provide desired output:
package p1;
abstract class LivingThings{
public abstract void resperate();
interface Living
{
public abstract void walk();
}
}
class Human implements LivingThings.Living{
@Override
public void walk() {
System.out.println("Human Can Walk");
}
}
class Test {
public static void main(String[] args) {
new Human().walk();
}
} TRUE

Carefully read the question and answer accordingly.


State whether TRUE or FALSE.
An overriding method can also return a subtype of the type returned
by the overridden method. TRUE
Carefully read the question and answer accordingly.
abstract public class Employee
{
protected abstract double getSalesAmount();
public double getCommision() {
return getSalesAmount() * 0.15;
}
}
class Sales extends Employee
{
// insert method here
}
Which two methods, inserted independently, correctly complete the
Sales
class?
1.double getSalesAmount() { return 1230.45; }
2. public double getSalesAmount() { return 1230.45; }
3.private double getSalesAmount() { return 1230.45; }
4.protected double getSalesAmount() { return 1230.45; } 1&2

Carefully read the question and answer accordingly.


State whether TRUE or FALSE.
The below code will compile & provide desired output:
package p1;
interface A {
public abstract void methodOne();
}
interface B extends A {
public abstract void methodTwo();
}
class C implements B{
@Override
public void methodTwo() {
System.out.println("Method Two Body");
}
}
class Test {
public static void main(String[] args) {
new C().methodTwo();
}
} TRUE
Carefully read the question and answer accordingly.
interface B
{
public void bM1();
public void bM2();
}
abstract class A implements B
{
public abstract void aM1();
public abstract void aM2();
public void bM1(){}
}
public class Demo extends A
{
}
In above scenario class Demo must override which methods? public void aM2(){}

Carefully read the question and answer accordingly.


State whether TRUE or FALSE.
Interface can be used when common functionalities have to be
implemented differently across multiple classes. TRUE

Carefully read the question and answer accordingly.


State whether TRUE or FALSE.
The below code will compile & provide desired output:
package p1;
interface A {
public abstract void methodOne();
}
interface B{
public abstract void methodTwo();
}
interface C{
public abstract void methodTwo();
}
class D implements B,C,A{
public void methodOne(){}
public void methodTwo(){ System.out.println("Method Two");}
}
class Test {
public static void main(String[] args) {
new D().methodTwo();
}
} TRUE
Carefully read the question and answer accordingly.
public class Person
{
private String name;
public Person(String name) { this.name = name; }
public boolean equals(Person p)
{
return p.name.equals(this.name); The equals method does
} NOT properly override the
} Object class's equals
Which statement is true? method.

Carefully read the question and answer accordingly.


Which of the following keywords ensures that a method cannot be
overridden? final

Carefully read the question and answer accordingly.


What is the outputof below code:
package p1;
abstract class LivingThings{
public abstract int walk();
}
class Human extends LivingThings{
@Override
public void walk() {
System.out.println("Human Can Walk");
}
}
class Test {
public static void main(String[] args) {
new Human().walk();
}
} Human Can Walk
Carefully read the question and answer accordingly.
What will be the output of following code?
class InterfaceDemo
{
public static void main(String [] args)
{
new DigiCam(){}.doCharge();
new DigiCam(){
public void writeData (String msg)
{
System.out.println("You are Sending: "+msg);
}
}.writeData("MyFamily.jpg");
}//main
}
interface USB
{
int readData();
void writeData(String input);
void doCharge();
}
abstract class DigiCam implements USB
{
public int readData(){ return 0;}
public void writeData(String input){}
public void doCharge()
{
System.out.println("DigiCam do Charge");
} DigiCam do Charge You are
} Sending: MyFamily.jpg

Carefully read the question and answer accordingly.


What is the output of below code:
package p1;
public class Test {
public static void main(String[] args) {
Test t1 = new Test();
Test t2 = new Test();
if (!t1.equals(t2))
System.out.println("they're not equal");
if (t1 instanceof Object)
System.out.println("t1's an Object");
}
} they're not equal

Carefully read the question and answer accordingly.


State whether TRUE or FALSE.
A concrete class can extend more than one super class whether that
super class is either concrete or abstract class TRUE
Carefully read the question and answer accordingly.
public class Client1
{
public static void main(String [] args)
{
PenDrive p;
PenDrive.Vendor v1=new PenDrive.Vendor("WD",500);
System.out.println(v1.getName());
System.out.println(v1.getPrice());
}
}
class PenDrive
{
static class Vendor
{
String name;
int price;
public String getName(){ return name;}
public int getPrice(){ return price;}

Vendor(String name,int price)


{
this.name=name;
this.price=price;
}
}
} Class cannot be defined
What will be the output of the given code? inside another class

Carefully read the question and answer accordingly.


State whether TRUE or FALSE.
The super() call can only be used in constructor calls and not method
calls. TRUE

Carefully read the question and answer accordingly.


Abstract classes can be used when
Statement I: Some implemented functionalities are common between
classes
Statement II: Some functionalities need to be implemented in sub
classes that extends the abstract class Statement I & II are TRUE
Carefully read the question and answer accordingly.
class InterfaceDemo
{
public static void main(String [] args)
{
DigiCam cam1=new DigiCam();
cam1.doCharge();
}//main
}
interface USB
{
int readData();
boolean writeData(String input);
void doCharge();
}
class DigiCam implements USB
{
public int readData(){ return 0;}
public boolean writeData(String input){ return false; }
void doCharge(){ return;}
} Code will not compile due to
Which of the following is correct with respect to given code? weaker access privilege.

Carefully read the question and answer accordingly.


State whether TRUE or FALSE.
Object class provides a method named getClass() which returns
runtime class of an object. TRUE

Carefully read the question and answer accordingly.


What will be the output for following code?
public class VariableDec1
{
public static void main(String[]args)
{
int I=32;
char c=65;
char a=c+I;
System.out.println(a);
}
} 97

Carefully read the question and answer accordingly.


Which of the following code snippets make objects eligible for
Garbage Collection?
Statement A: String s = "new string"; s = s.replace('e', '3');
Statement B:String replaceable = "replaceable"; StringBuffer sb = new
StringBuffer(replaceable);replaceable = null; sb = null; Both Statements A and B
Carefully read the question and answer accordingly.
Members of the classs are accessed by _________ operator address

Carefully read the question and answer accordingly.


Which of the following is the correct syntax for suggesting that the
JVM to performs garbage collection? System.free();

Carefully read the question and answer accordingly.


What will be the output for following code?
public class VariableDec
{
public static void main(String[]args)
{
int x = 1;
if(x>0 )
x = 3;
switch(x)
{
case 1: System.out.println(1);
case 0: System.out.println(0);
case 2: System.out.println(2);
break;
case 3: System.out.println(3);
default: System.out.println(4);
break;
}
}
} 102

Carefully read the question and answer accordingly.


_____________ Operator is used to create an object. class

Carefully read the question and answer accordingly.


Which of the following is not the Java keyword? extends

Carefully read the question and answer accordingly.


Find the keyword(s) which is not used to implement exception try

Carefully read the question and answer accordingly.


The ++ operator postfix and prefix has the same effect TRUE
Carefully read the question and answer accordingly.
What will be the output for following code?
public class Operators
{
public static void main(String[]args)
{
int i=12;
int j=13;
int k=++i-j--;
System.out.println(i);
System.out.println(j);
System.out.println(k);
}
} 12,12,-1

Carefully read the question and answer accordingly.


What will be the output for following code?
public class Variabledec {
public static void main(String[]args){
boolean x = true;
int a;
if(x) a = x ? 2: 1;
else a = x ? 3: 4;
System.out.println(a);
}
} 1

Carefully read the question and answer accordingly.


What is the correct structure of a java program?
I: import statement
II: class declaration (pic)
III: package statement
IV: method,variable declarations III->I->II->IV.

Carefully read the question and answer accordingly.


Garbage collector thread is a daemon thread.
State True or False. TRUE

Carefully read the question and answer accordingly.


Garbage collection guarantee that a program will not run out of
memory. State True or False. FALSE

Carefully read the question and answer accordingly.


Statement A:finalize will always run before an object is garbage
collected
Statement B:finalize method will be called only once by the garbage
collector Both Statements A and B
which of the following is true? are true
Carefully read the question and answer accordingly.
After which line the object initially referred by str ("Hello" String object)
is eligible for garbage collection?
class Garbage{
public static void main(string[]args){
line 1:String str=new String("Hello");
line 2. String str1=str;
line 3.str=new String("Hi");
line 4.str1=new String("Hello Again");
5.return;
}
} line 3

Carefully read the question and answer accordingly.


How can you force garbage collection of an object?
1.Garbage collection cannot be forced
2.Call System.gc().
3.Call Runtime.gc().
4. Set all references to the object to new values(null, for example). Option 2

Carefully read the question and answer accordingly.


Which of the below is invalid state of thread? Runnable

Carefully read the question and answer accordingly.


Predict the output of below code:
package p1;
class MyThread extends Thread {
public void run(int a) {
System.out.println("Important job running in MyThread");
}
public void run(String s) {
System.out.println("String in run");
}
}
class Test {
public static void main(String[] args) {
MyThread t1=new MyThread();
t1.start();
}
} Compile Error

Carefully read the question and answer accordingly. Reduce response time of
Which of these is not a benefit of Multithreading? process.
Carefully read the question and answer accordingly.
You have created a TimeOut class as an extension of Thread, the
purpose of which is to print a “Time’s Over” message if the Thread is
not interrupted within 10 seconds of being started. Here is the run
method that you have coded:
public void run() {
System.out.println(“Start!”);
try {
Thread.sleep(10000);
System.out.println(“Time’s Over!”);
} catch (InterruptedException e) {
System.out.println(“Interrupted!”); Exactly 10 seconds after the
} start method is called,
}Given that a program creates and starts a TimeOut object, which of “Time’s Over!” will be
the following statements is true? printed.

Carefully read the question and answer accordingly.


Synchronization is achieved by using which of the below methods Synchronized blocks

Carefully read the question and answer accordingly.


State whether TRUE or FALSE.
The below code will compile & provide desired output:
package p1;
class MyThread extends Thread {
public void run() {
System.out.println("Important job running in MyThread");
}
public void run(String s) {
System.out.println("String in run is " + s);
}
}
class Test {
public static void main(String[] args) {
MyThread t1=new MyThread();
t1.start();
}
} TRUE
Carefully read the question and answer accordingly.
What will be the output of below code:
package p1;
class MyThread extends Thread {
public void run() {
System.out.println("Important job running in MyThread");
}
}
class Test {
public static void main(String[] args) {
MyThread t1=new MyThread();
t1.run();
}
} Compile Error

Carefully read the question and answer accordingly.


public class Threads
{
public static void main (String[] args)
{
new Threads().go();
}
public void go()
{
Runnable r = new Runnable()
{
public void run()
{
System.out.print("Run");
}
};

Thread t = new Thread(r);


t.start();
t.start();
}
} An exception is thrown at
What will be the result? runtime.

Carefully read the question and answer accordingly.


Inter thread communication is achieved using which of the below
methods? wait()

Carefully read the question and answer accordingly.


Which of these is not valid method in Thread class void run()

Carefully read the question and answer accordingly.


State whether TRUE or FALSE.
Threads are small process which run in shared memory space within
a process. TRUE
Carefully read the question and answer accordingly.
Which of the following statements are true?
Statement1: When a thread is sleeping as a result of sleep(), it
releases its locks.
Statement2: The Object.wait() method can be invoked only from a Statement1 is TRUE but
synchronized context. Statement2 is FALSE.

Carefully read the question and answer accordingly.


Which two statements are true?
1.It is possible for more than two threads to deadlock at once.
2.The JVM implementation guarantees that multiple threads cannot
enter into a
deadlocked state.
3.Deadlocked threads release once their sleep() method's sleep
duration has expired.
4.If a piece of code is capable of deadlocking, you cannot eliminate
the possibility of
deadlocking by inserting
invocations of Thread.yield(). 1&2

Carefully read the question and answer accordingly.


public class TestDemo implements Runnable
{
public void run()
{
System.out.print("Runner");
}
public static void main(String[] args)
{
Thread t = new Thread(new TestDemo());
t.run();
t.run();
t.start();
} You cannot call run()
} method using Thread class
What will be the result? object.

Carefully read the question and answer accordingly.


class Background implements Runnable{
int i = 0;
public int run(){
while (true) {
i++;
System.out.println("i="+i);
}
return 1; It will compile and the run
} method will print out the
}//End class increasing value of i.
Carefully read the question and answer accordingly.
Java provides ____ ways to create Threads. One

Carefully read the question and answer accordingly.


As per the below code find which statements are true.
public class Test {
public static void main(String[] args) {
Line 1: ArrayList<String> myList=new List<String>();
Line 2: String string = new String();
Line 3: myList.add("string");
Line 4: int index = myList.indexOf("string");
System.out.println(index);
}
} Line 1 has compilation error

Carefully read the question and answer accordingly.


The ArrayList<String> is immutable. TRUE

Carefully read the question and answer accordingly.


Map is the super class of Dictionary class? TRUE

Carefully read the question and answer accordingly.


Method keySet() in Map returns a set view of the keys contained in
that map.
State True or False. TRUE

Carefully read the question and answer accordingly.


Is "Array" a subclass of "Collection" ? TRUE

Carefully read the question and answer accordingly.


What will be the output for following code?
public class Compare
{
public static void main(String[]args)
{
String s=new String("abc");
String s1=new String("abc");
System.out.println(s.compareTo(s1));
}
} True

Carefully read the question and answer accordingly.


The LinkedList class supports two constructors. TRUE
Carefully read the question and answer accordingly.
Consider the following statements about the Map type Objects:
Statement A: Changes made in the set view returned by keySet() will
be reflected in the original map.
Statement B: All Map implementations keep the keys sorted. Both Statements A and B
Which of the following option is true regarding the above statements? are true

Carefully read the question and answer accordingly.


what is the way to iterate over the elements of a Map for loop

Carefully read the question and answer accordingly.


Consider the following partial code:
java.util.Date date = new java.util.Date();
Which of the following statement is true regarding the above partial Creates a Date object with 0
code? as default value

Carefully read the question and answer accordingly.


Consider the following list of code:
A) Iterator iterator = hashMap.keySet().iterator();
B) Iterator iterator = hashMap.iterator();
C) Iterator iterator = hashMap.keyMap().iterator();
D) Iterator iterator = hashMap.entrySet().iterator();
E) Iterator iterator = hashMap.entrySet.iterator();
Assume that hashMap is an instance of HashMap type collection
implementation.
Which of the following option gives the correct partial code about
getting an Iterator to the HashMap entries? A

Carefully read the question and answer accordingly.


What is the return type of next() in Iterator? boolean

Carefully read the question and answer accordingly.


foreach loop is the only option to iterate over a Map TRUE

Carefully read the question and answer accordingly.


Which of the following are not List implementations?
1.Vector
2.Hashtable
3.LinkedList
4.Properties 1&2
Carefully read the question and answer accordingly.
Consider the following Statements:
Statement A: The Iterator interface declares only two methods:
hasMoreElements and nextElement.
Statement B: The ListIterator interface extends both the List and
Iterator interfaces.
Which of the following option is correct regarding above given Both the Statements A and
statements? B are true

Carefully read the question and answer accordingly.


State TRUE or FALSE.
line 1: public class Test {
line 2: public static void main(String[] args) {
line 3: Queue queue = new LinkedList();
line 4: queue.add("Hello");
line 5: queue.add("World");
line 6: List list = new ArrayList(queue);
line 7: System.out.println(list); }
line 8: }
Above code will give run time error at line number 3. TRUE

Carefully read the question and answer accordingly.


Iterator i= new HashMap().entrySet().iterator();
is this correct declaration TRUE

Carefully read the question and answer accordingly.


Iterator is having previous() method.
State True or False. FALSE

Carefully read the question and answer accordingly.


List<Integer> newList=new ArrayList<integer>(); will Above
statement create a new object of Array list successfully ? TRUE

Carefully read the question and answer accordingly.


Which collection class allows you to associate its elements with key
values java.utill.Map

Carefully read the question and answer accordingly.


Under  java.util package we have "Collections" as Class and
"Collection" as Interface  TRUE

Carefully read the question and answer accordingly.


The add method of Set returns false if you try to add a duplicate
element. TRUE

Carefully read the question and answer accordingly.


Is this true or false. Map interface is derived from the Collection
interface. TRUE
Carefully read the question and answer accordingly.
LinkedList represents a collection that does not allow duplicate
elements. TRUE

Carefully read the question and answer accordingly.


What is the data type of m in the following code?
import java.util.*;
public class set1
{
public static void main(String [] args)
{
Set s=new HashSet();
s.add(20);
s.add("abc");
for( _____ m:s)
System.out.println(m);
}
} int

Carefully read the question and answer accordingly.


Which of these interface(s) are part of Java’s core collection
framework? List

Carefully read the question and answer accordingly.


When comparable interface is used which method should be
overridden? comparator

Carefully read the question and answer accordingly.


TreeSet uses which two interfaces to sort the data Serializable

The elements in the


Carefully read the question and answer accordingly. collection are accessed
Which statement are true for the class HashSet? using a non-unique key.

Carefully read the question and answer accordingly.


Enumeration is having remove() method.
State True or False. FALSE

Carefully read the question and answer accordingly.


Consider the following code:
01 import java.util.Set;
02 import java.util.TreeSet;
03
04 class TestSet {
05 public static void main(String[] args) {
06 Set set = new TreeSet<String>();
07 set.add("Green World");
08 set.add(1);
09 set.add("Green Peace");
10 System.out.println(set);
11 } Prints the output [Green
12 } World, 1, Green Peace] at
Which of the following option gives the output for the above code? line no 9
Carefully read the question and answer accordingly.
What will be the output for following code?
public class collection1{
public static void main(String[]args){
Collection c=new ArrayList();
c.add(10);
c.add("abc");
Collection l=new HashSet();
l.add(20);
l.add("abc");
l.add(30);
c.addAll(l);
c.removeAll(l);
System.out.println( c );
}
} [10,abc]
Carefully read the question and answer accordingly.
Which of these are interfaces in the collection framework Hash Map
The Iterator interface
declares only three
Carefully read the question and answer accordingly. methods: hasNext, next and
Which of the following are true statements? remove.

Carefully read the question and answer accordingly.


which are the Basic features of implementations of interfaces in All implementations are
Collections Framework in java? unsynchronized

Carefully read the question and answer accordingly.


Which of the following are synchronized?
1.Hashtable
2.Hashmap
3.Vector
4.ArrayList 1&2

Carefully read the question and answer accordingly.


What will be the output for following code?
import java.util.*;
public class StringTokens
{
public static void main(String[]args)
{
String s="India is a\n developing country";
StringTokenizer o=new StringTokenizer(s);
System.out.println(o.countTokens());
}
} 4

Carefully read the question and answer accordingly.


State whether TRUE or FALSE.
StringBuilder is not thread-safe unlike StringBuffer TRUE
Carefully read the question and answer accordingly.
What will be the output for following code?
public class StringCompare{
public static void main(String[]args){
if("string"=="string")
System.out.println("both strings are equal");
else
System.out.println("both strings are not equal");
}
} both strings are equal

Carefully read the question and answer accordingly.


endsWith() member methods of String class creates new String
object. State True or False TRUE

Carefully read the question and answer accordingly.


What will be the output for following code?
public class CompareStrings{
public static void main(String[]args){
String a=new String("string");
String s=new String("string");
if(a==s)
System.out.println("both strings are equal");
else
System.out.println("both strings are not equal");
}
} both strings are equal

Carefully read the question and answer accordingly.


State whether TRUE or FALSE.
String s = new String(); is valid statement in java TRUE

Carefully read the question and answer accordingly.


What is the output of below code:
package p1;
public class Hackathon {
public static void main(String[] args) {
String x = "Java";
x.concat(" Rules!");
System.out.println("x = " + x);
}
} x = Java Rules

Carefully read the question and answer accordingly.


State whether TRUE or FALSE.
StringTokenizer implements the Enumeration interface TRUE

Carefully read the question and answer accordingly.


State whether TRUE or FALSE.
The APIS of StringBuffer are synchronized unlike that of StringBuilder TRUE
Carefully read the question and answer accordingly.
What is the output of below code:
package p1;
public class Hackathon {
public static void main(String[] args) {
String x = "Java";
x.toUpperCase();
System.out.println("x = " + x);
}
} x = JAVA

Carefully read the question and answer accordingly.


Consider the following code snippet:
String thought = "Green";
StringBuffer bufferedThought = new StringBuffer(thought);
String secondThought = bufferedThought.toString();
System.out.println(thought == secondThought);
Which of the following option gives the output of the above code
snippet? TRUE

Carefully read the question and answer accordingly.


Choose the correct option.
Statement I: StringBuilder offers faster performance than StringBuffer
Statement II: All the methods available on StringBuffer are also
available on StringBuilder Statement I & II are TRUE

Carefully read the question and answer accordingly.


String class contains API used for Comparing strings

Carefully read the question and answer accordingly.


Choose the correct option.
Statement I: StringBuffer is efficient than “+” concatenation
Statement II: Using API’s in StringBuffer the content and length of
String can be changed which intern creates new object. Statement I & II are TRUE

Carefully read the question and answer accordingly.


State whether TRUE or FALSE.
String class do not provides a method which is used to compare two
strings lexicographically. TRUE
Carefully read the question and answer accordingly.
What will be the output for following code?
public class CompareStrings{
public static void main(String[]args){
if(" string ".trim()=="string")
System.out.println("both strings are equal");
else
System.out.println("both strings are not equal");
}
} both strings are equal

Carefully read the question and answer accordingly.


What will be the output for following code?
public class StringBuffer1
{
public static void main(String[]args)
{
StringBuffer s1=new StringBuffer("welcome");
StringBuffer s2=new StringBuffer("welcome");
System.out.println(s1.equals(s2));
System.out.println(s1.equals(s1));
}
} true false

Carefully read the question and answer accordingly.


What will be the output for following code?
import java.io.*;
public class Exception1
{
public static void main(String[]args)
{
System.out.println("A");

try
{
}
catch(IOException t)
{
System.out.println("B");
}

System.out.println("C");
}
} Compile time error
Carefully read the question and answer accordingly.
What will be the output of the program?
public class Test {
public static void aMethod() throws Exception {
try {
throw new Exception();
} finally {
System.out.print("finally");
}
}
public static void main(String args[]) {
try {
aMethod();
} catch (Exception e) {
System.out.print("exception ");
}
System.out.print("finished"); /* Line 24 */
}
} exception finished

Carefully read the question and answer accordingly.


At Point X in below code, which code is necessary to make the code
compile?
public class Test
{
class TestException extends Exception {}
public void runTest() throws TestException {}
public void test() /* Point X */
{
runTest();
}
} throws RuntimeException

Carefully read the question and answer accordingly.


If you put a finally block after a try and its associated catch blocks,
then once execution enters the try block, the code in that finally block
will definitely be executed except in some circumstances.select the An exception arising in the
correct circumstance from given options: finally block itself
Carefully read the question and answer accordingly.
What will be the output of the below code?
public class Test {
public static void main(String[] args) {
int a = 5, b = 0, c = 0;
String s = new String();
try {
System.out.print("hello ");
System.out.print(s.charAt(0));
c = a / b;
} catch (ArithmeticException ae) {
System.out.print(" Math problem occur");
} catch (StringIndexOutOfBoundsException se) {
System.out.print(" string problem occur");
} catch (Exception e) {
System.out.print(" problem occurs");
} finally {
System.out.print(" stopped");
}
}
} hello 0 stopped

Carefully read the question and answer accordingly.


Within try block if System.exit(0) is called then also finally block is
going to be executed.
State True or False. FALSE

Carefully read the question and answer accordingly.


Which of the following are checked exceptions?
1.ClassNotFoundException
2.InterruptedException
3.NullPointerException
4.ArrayIndexOutOfBoundsException 1&2

Carefully read the question and answer accordingly.


which of these are the subclass of Exception class IOException

Runtime exceptions need


not be explicitly caught in try
Carefully read the question and answer accordingly. catch block as it can occur
what are true for RuntimeException anywhere in a program.
Carefully read the question and answer accordingly.
What will be the output of following code?
try
{
System.out.println("Executing try");
}
System.out.println("After try");
catch (Exception ex)
{
System.out.println("Executing catch"); Executing try After try
} Executing catch

Carefully read the question and answer accordingly.


Consider the following code:
class MyException extends Throwable { }
public class TestThrowable {
public static void main(String args[]) {
try {
test();
} catch(Throwable ie) {
System.out.println("Exception");
}
}

static void test() throws Throwable {


throw new MyException();
}
}
Which of the following option gives the output for the above code? Prints Exception

Carefully read the question and answer accordingly.


which are the Unchecked exceptions Class Cast Exception

Carefully read the question and answer accordingly.


What will be the output for following code?
public class Exception1
{
public static void main(String[]args)
{
System.out.println("A");
try
{
System.exit(0);
}catch(Exception e)
{
System.out.println("B");
}
System.out.println("C");
}
}
} A,C
A ClassNotFoundException
is thrown when the reported
class is not found by the
Carefully read the question and answer accordingly. ClassLoader in the
Which is/are true among given statements CLASSPATH.

Carefully read the question and answer accordingly.


What will be the output for following code?
public class Exe3
{
public static void main(String[]args)
{
try
{
int i=10;
int j=i/0;
return;
}catch(Exception e)
{
System.out.println("welcome");
}
System.out.println("error");
}
}
1.welcome
2.error
3.compilation error 1&2

Carefully read the question and answer accordingly. Try block always needed a
which are true for try block catch block followed
Carefully read the question and answer accordingly.
What will be the output of following code?
public class Exception1{
public static void main(String args[]) {
int i=1, j=1;
try {
i++;
j--;
if(i/j > 1)
i++;
} catch(ArithmeticException e) {
System.out.println(0);
} catch(ArrayIndexOutOfBoundsException e) {
System.out.println(1);
} catch(Exception e) {
System.out.println(2);
}
finally {
System.out.println(3);
}
System.out.println(4);
}
}
1.0
2.1
3.3
4.4. 1&2

Carefully read the question and answer accordingly.


Consider the following code:
1 public class FinallyCatch {
2 public static void main(String args[]) {
3 try {
4 throw new java.io.IOException();
5 }
6 } Shows unhandled exception
7 } type IOException at line
Which of the following is true regarding the above code? number 4

Carefully read the question and answer accordingly.


Which of the following exception is not mandatory to be handled in
code? IOException
Carefully read the question and answer accordingly.
What will be the output for following code?
public class Exception1{
public static void main(String args[]) {
int i=1, j=1;
try {
i++;
j--;
if(i/j > 1)
i++;
} catch(Exception e) {
System.out.println(2);
} catch(ArithmeticException e) {
System.out.println(0);
}
finally {
System.out.println(3);
}
}
} 2

Carefully read the question and answer accordingly.


select true or false . Statement : Throwable is the super class of all
exceptional type classes. TRUE

Carefully read the question and answer accordingly.


try and throws keywords are used to manually throw an exception? TRUE

Carefully read the question and answer accordingly.


RuntimeException is the superclass of those exceptions that can be
thrown during the normal operation of the Java Virtual Machine. TRUE

Carefully read the question and answer accordingly.


Which of the following statement is true regarding implementing user
defined exception mechanisms?
Statement A: It is valid to derive a class from java.lang.Exception
Statement B: It is valid to derive a class from Both Statements A and B
java.lang.RuntimeException are true
An exception which is not
handled by a catch block
Carefully read the question and answer accordingly. will be handled by
Which of the following statement is true regarding try-catch-finally? subsequent catch blocks

Carefully read the question and answer accordingly.


Which of these keywords are a part of exception handling? try

Carefully read the question and answer accordingly.


Error is the sub class of Throwable TRUE
Carefully read the question and answer accordingly.
Which of these keywords is used to explicitly throw an exception? try

Carefully read the question and answer accordingly.


is it valid to place some code in between try and catch blocks. TRUE

Carefully read the question and answer accordingly. A checked exception is a


which are correct for checked exceptions subclass of throwable class

Carefully read the question and answer accordingly.


Try can be followed with either catch or finally.
State True or False. TRUE

Carefully read the question and answer accordingly.


Which is the super class for Exception and Error? Throwable

Carefully read the question and answer accordingly.


The finally block always executes when the try block exits.
State True or False. TRUE

Carefully read the question and answer accordingly.


Select two runtime exceptions.
1.SQLException
2.NullPointerException
3.FileNotFoundException
4.ArrayIndexOutOfBoundsException
5.IOException 1&2

Carefully read the question and answer accordingly.


Propagating exceptions across modules is not possible without throw
and throws keyword. State True or False. TRUE
Carefully read the question and answer accordingly.
What will be the output for following code?
public class Exe3 {
public static void main(String[]args){
try{
int i=10;
int j=i/0;
return;
}catch(Exception e){
try{
System.out.println("welcome");
return;
}catch(Exception e1){
}
System.out.println("error");
}
}
} welcome

Carefully read the question and answer accordingly.


What will be the output for following code?
class super5{
void Get()throws Exception{
System.out.println("IOException");
}
}
public class Exception2 extends super5{
public static void main(String[]args){
super5 o=new super5();
try{
o.Get();
}catch(IOException e){
}
}
} IOException

Carefully read the question and answer accordingly.


Serialization is representing object in a sequence of bytes. State True
or False. TRUE

Carefully read the question and answer accordingly.


Serialization is JVM independent.State True or False. TRUE

Carefully read the question and answer accordingly.


Statement 1:static variables can be serialized
Statement2:transient variables cannot be serialized statement 1:true
which of the following is true? statement2:true
BufferedOutputStream class
Carefully read the question and answer accordingly. is a member of Java.io
select the correct statements about BufferedOutputStream class package

Carefully read the question and answer accordingly.


DataInputStream is not necessarily safe for multithreaded access. TRUE

Carefully read the question and answer accordingly.


Which of the following is a marker interface used for object
serialization? Runnable

Carefully read the question and answer accordingly.


InputStream is the class used for stream of characters.
State True or False. FALSE

Carefully read the question and answer accordingly.


BufferedWriter constructor CAN ACCEPT Filewriter Object as a
parameter.
State True or False. TRUE

Carefully read the question and answer accordingly.


Which of these class are the member class of java.io package? ObjectInput

Carefully read the question and answer accordingly.


Which of these interface is not a member of java.io package? DataInput

Carefully read the question and answer accordingly.


Which of the following are abstract classes?
1.Reader
2.InputStreamReader
3.InputStream
4.OutputStream 1&2

Carefully read the question and answer accordingly.


An ObjectInputStream deserializes objects previously written using an
ObjectOutputStream.
State True or False. TRUE
Carefully read the question and answer accordingly.
The InputStream.close() method closes this stream and releases all
system resources TRUE

Carefully read the question and answer accordingly.


State TRUE or FALSE.
getParent() gives the parent directory of the file and isFile() Tests
whether the file denoted by the given abstract pathname is a normal
file. TRUE

Carefully read the question and answer accordingly.


InputStreamReader is sub class of FilterReader. TRUE

Carefully read the question and answer accordingly.


isFile() returns true if called on a file or when called on a directory TRUE

Carefully read the question and answer accordingly.


What is the output of this program?
1. import java.io.*;
2. class files {
3. public static void main(String args[]) {
4. File obj = new File("/java/system");
5. System.out.print(obj.getName());
6. }
7. } java/system

Carefully read the question and answer accordingly.


Which of these class are related to input and output stream in terms of
functioning? File

Carefully read the question and answer accordingly.


The ______ statement is used inside the switch to terminate a
Statement sequence break

Carefully read the question and answer accordingly.


The result of 10.987+”30.765” is _________________. 10.98730.765

Carefully read the question and answer accordingly.


Data can be passed to the function ____ by value

Carefully read the question and answer accordingly.


_____________ is a multi way branch statement switch

Carefully read the question and answer accordingly.


Which of the following is a loop construct that will always be executed
once? switch
Carefully read the question and answer accordingly.
What will be the output for following code?
public class While {
static int i;
public static void main(String[]args){
System.out.println(i);
while(i<=5){
i++;
}
System.out.println(i);
}
} compilation error

Carefully read the question and answer accordingly. The number of bytes is
What is the number of bytes used by Java primitive long compiler dependent

Carefully read the question and answer accordingly.


We can use Wrapper objects of type int, short, char in switch case.
State True or False. TRUE

Carefully read the question and answer accordingly.


What happens when the following code is compiled and run. Select
the one correct
answer.
for(int i = 1; i < 3; i++) The class compiles and
for(int j = 3; j >= 1; j--) runs, but does not print
assert i!=j : i; anything.

Carefully read the question and answer accordingly.


What will be the output for following code?
public class WrapperClass12
{
public static void main(String[]args)
{
Boolean b=true;
boolean a=Boolean.parseBoolean("tRUE");
System.out.println(b==a);
}
} True

Carefully read the question and answer accordingly.


What will be the output for following code?
public class WrapperClass1 {
public static void main(String[]args){
String s="10Bangalore";
int i=Integer.parseInt(s);
System.out.println(i);
}
} 10Bangalore
Carefully read the question and answer accordingly.
What will be the output for following code?
public class While {
public static void main(String[]args){
int a='A';
int i=a+32;
while(a<='Z'){
a++;
}
System.out.println(i);
System.out.println(a);
}
} A,Z

Carefully read the question and answer accordingly.


What will be the output for following code?
public class WrapperClass1 {
public static void main(String[]args){
Integer i=new Integer(10);
Integer j=new Integer(10);
System.out.println(i==j);
}
} True

Carefully read the question and answer accordingly.


What will be the output for following code?
public class Wrapper2 {
public static void main(String[]args){
Byte b=1;
Byte a=2;
System.out.println(a+b);
}
} compiles and print 3

Carefully read the question and answer accordingly.


What will be the output for following code?
public class Wrapper11
{
public static void main(String[]args)
{
Long l=100;
System.out.println(l);
}
} 100
Carefully read the question and answer accordingly.
What will be the output of below code?
public class Test {
public static void main(String[] args) {
int i = 1;
Integer I = new Integer(i);
method(i);
method(I);
}
static void method(Integer I) {
System.out.print(" Wrapper");
}
static void method(int i) {
System.out.print(" Primitive");
}
} Primitive Wrapper

Carefully read the question and answer accordingly.


What is the value of variable "I" after execution of following code?
public class Evaluate
{
public static void main(String[]args)
{
int i=10;
if(((i++)>12)&&(++i<15))
System.out.println(i);
else
System.out.println(i);
}
} 10

Carefully read the question and answer accordingly.


Each case in switch statement should end with ________ statement default

Carefully read the question and answer accordingly.


Type 1 & Type 3 driver types are not vendor specific implementation
of Java driver. State True or False TRUE

Carefully read the question and answer accordingly.


The JDBC-ODBC Bridge driver translates the JDBC API to the ODBC
API and used with which of the following: JDBC drivers

Carefully read the question and answer accordingly.


A Java program cannot directly communicate with an ODBC driver
because of which of the following: ODBC written in C language
Carefully read the question and answer accordingly.
Which statements about JDBC are true?
1.JDBC has 5 types of Drivers
2.JDBC stands for Java DataBase Connectivity
3.JDBC is an API to access relational databases, spreadsheets and
flat files
4.JDBC is an API to bridge the object-relational mismatch between
OO programs and relational databases 1&2

Carefully read the question and answer accordingly.


Which type of driver converts JDBC calls into the network protocol
used by the database management system directly? Type 1 driver

Carefully read the question and answer accordingly.


Which type of Statement can execute parameterized queries? PreparedStatement

Carefully read the question and answer accordingly.


Connection object can be initialized using which method of the Driver
Manager class? r

Carefully read the question and answer accordingly.


Which of the following is true with respect to code given below?
import java.sql.*;
public class OracleDemo
{
public static void main(String [] args) throws
SQLException,ClassNotFoundException
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection
con=DriverManager.getConnection("jdbc:oracle:thin:@PC188681:152
1:training","scott","tiger");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("SELECT * FROM Person");
while(rs.next())
{
System.out.println(rs.getString("column1"));
}
} The code will not compile as
} no try catch block specified
Carefully read the question and answer accordingly.
If your JDBC Connection is in auto-commit mode, which it is by
default, then every SQL statement is committed to the database upon
its completion. State True or False. TRUE

Carefully read the question and answer accordingly. Call method execute() on a
How can you execute a stored procedure in the database? CallableStatement object

Carefully read the question and answer accordingly.


Consider the following statements:
Statement A: The PreparedStatement object enables you to execute
parameterized queries.
Statement B: The SQL query can use the placeholders which are
replaced by the INPUT parameters at runtime.
Which of the following option is True with respect to the above Both Statement A and
statements? Statement B are True.

Carefully read the question and answer accordingly.


You are using JDBC-ODBC bridge driver to establish a connection Connection
with a database. You have created a DSN Mydsn. Which statement cn=DriverManager.getConn
will you use to connect to the database? ection("jdbc:odbc");

Carefully read the question and answer accordingly.


Which of the following listed option gives the valid type of object to
store a date and time combination using JDBC API? java.util.Date

Carefully read the question and answer accordingly.


Which method executes an SQL statement that may return multiple
results? executeUpdate()

Carefully read the question and answer accordingly.


Which package contains classes that help in connecting to a
database, sending SQL statements to the database, and processing
the query results connection.sql

Carefully read the question and answer accordingly.


Which method sets the query parameters of the PreparedStatement
Object? putString()

DDL statements are treated


as normal SQL statements,
and are executed by calling
the execute() method on a
Carefully read the question and answer accordingly. Statement (or a sub
What is correct about DDL statements? interface thereof) object
Carefully read the question and answer accordingly.
What is the state of the parameters of the PreparedStatement object
when the user clicks on the Query button? initialized

Carefully read the question and answer accordingly.


executeUpdate() & execute() are valid methods that can be used for
executing DDL statements. State True or False TRUE

Carefully read the question and answer accordingly.


Which object provides you with methods to access data from the
table? ResultSet

Carefully read the question and answer accordingly.


The method Class.forName() is a part of JDBC API. State True or
False. TRUE

Carefully read the question and answer accordingly.


Which object allows you to execute parametrized queries? ResultSet

Carefully read the question and answer accordingly.


Which method executes a simple query and returns a single Result
Set object? executeUpdate()

Carefully read the question and answer accordingly.


Which packages contain the JDBC classes? java.jdbc and javax.jdbc

Carefully read the question and answer accordingly. select ename ,sal ,deptno
You are writing a query to select all employees whose salary is less from emp a where a.sal <
than the average of all the employees' salaries in the same (select avg(sal) from emp b
department. where a.deptno = b.deptno)
Which query will help you to achieve your goal? order by deptno;

Carefully read the question and answer accordingly.


With SQL, how can you find the range for the price between 2000 and
8000 in item table?
1.Select * from item where price between 2000 and 8000.
2.Select * from item where price >=2000 and price <=8000.
3.Select * from item where price <>2000 and price !=8000.
4.Select * from item where price >2000 and price <8000. 1&2
Carefully read the question and answer accordingly.
Examine the table structure of Employee
Ename Ecode Dept
John 1 Sal
Smith 3 Mar
Max 2 Sal
Joe 4 Mar
Laura 5 Dep
What will be the output of below query ?
select
decode(Ecode,5,'Department',4,'Marketing',3,’Marketing’,’Sales’) as
result from Employee; Query contains error

Carefully read the question and answer accordingly.


What will be the output of the query?
Select trim(0 from '00003443500') from dual? Query contains error

Carefully read the question and answer accordingly.


What will be the output of the below query? adds 10 seconds to the
select to_CHAR(sysdate+(10/1400),'HH:MI:SS') from dual; current Timestamp

Carefully read the question and answer accordingly.


Which of the following integrity rules of SQL states that if a relational
table has a foreign key, then every value of the foreign key must
either be null or match the values in the relational table in which that
foreign key is a primary key? Referential Integrity

Carefully read the question and answer accordingly.


What will be the result of the following code?
SELECT (2+3*4/2–5) FROM dual; 3

Carefully read the question and answer accordingly.


What will be the output of the below query?
select instr('My SQL World','a') from dual; Query contains error

Carefully read the question and answer accordingly.


What will be the output of the below query?
SELECT * FROM suppliers
WHERE supplier_name LIKE '!%' escape '!'; Query will generate an error
Carefully read the question and answer accordingly.
Statement A:Listener process scans for connection requests to an
Oracle Instance
Statement B:Listener process links up a dispatcher process to user
process. Both Statements A and B
which of the following is true? are true

Carefully read the question and answer accordingly.


What will be the output of the below query?
select Stud_name from (
select rank() over(order by Marks desc) as rank ,Stud_name from
StudentDetails
order by Stud_name --LINE 1 Top 2 student record with
) highest marks will be
where rank > 3 displayed

For using flashback query,


Carefully read the question and answer accordingly. the server need not be
Which of the following statement is True with respect to Query Flash configured to use Automatic
Back? Undo Management.

Carefully read the question and answer accordingly.


Identify the correct syntax to create a sequence which generates Create sequence MySeq
values as 2,4,6,8,10? Start with 2 Increment by 1

Carefully read the question and answer accordingly.


A dropped table can be restored by issuing this command.
FLASHBACK TABLE Supplier TO BEFORE DROP;
State True or False. TRUE

Carefully read the question and answer accordingly.


Evaluate the CREATE TABLE statement:
CREATE TABLE products
(product_id NUMBER(6) CONSTRAINT prod_id_pk PRIMARY KEY, It would be created only if a
product_name VARCHAR2(15)); unique index is manually
Which statement is true regarding the PROD_ID_PK constraint? created first.
Carefully read the question and answer accordingly.
Evaluate the following SQL statements that are issued in the given
order:
CREATE TABLE emp
(emp_no NUMBER(2) CONSTRAINT emp_emp_no_pk PRIMARY
KEY,
enameVARCHAR2(15),
salary NUMBER(8,2),
mgr_no NUMBER(2) CONSTRAINT emp_mgr_fk REFERENCES
emp);
ALTER TABLE emp
DISABLE CONSTRAINT emp_emp_no_pk CASCADE;
ALTER TABLE emp
ENABLE CONSTRAINT emp_emp_no_pk; It would be automatically
What would be the status of the foreign key EMP_MGR_FK? enabled and deferred.

Carefully read the question and answer accordingly.


Program Global Area (PGA) contain Data and control information for a
Server process? State True or False. TRUE

Carefully read the question and answer accordingly. Start an instance, Open the
Which of the following gives the order of Database administrative Database, Mount the
steps needed to open an Oracle Database? database

Carefully read the question and answer accordingly.


When Oracle starts an instance, it reads the server parameter file
called _______________. SYSOPER FILE

Carefully read the question and answer accordingly.


The user SCOTT who is the owner of ORDERS and SUPPLIERS
tables issues the following GRANT command:
GRANT ALL
ON orders, Suppliers TO PUBLIC; PUBLIC should be replaced
What correction needs to be done to the above statement? with specific usernames.

Carefully read the question and answer accordingly.


Which of the following is used to store the most recently executed
SQL statements and the most recently used data definitions? Data Pool

Carefully read the question and answer accordingly. A column contains a wide
Identify the circumstance under which you will create an Index? range of values.
Carefully read the question and answer accordingly.
You are using the system account to create a synonym as follows: A synonym with the name
Create synonym User for UserDetails UserDetails is created and
Which statements are true with respect to the above synonym? only system can access it

Carefully read the question and answer accordingly.


Oracle instance comprises of background processes and memory
structure. State True or False. TRUE

Carefully read the question and answer accordingly.


In Oracle10g database, control files contain information that describes
the names, locations, and sizes of the database files. State true or
False. TRUE

Carefully read the question and answer accordingly. PURGE


How to drop all tables from recycle bin? DBA_RECYCLEBIN

Carefully read the question and answer accordingly.


Which of the following parameter in Query Flashback clearly defines
the maximum time period that the database can be flashbacked? UNDO_MANAGEMENT

Carefully read the question and answer accordingly.


When a database is created the users SYS and SYSTEM are created
automatically and granted the DBA role. State True or False. TRUE

Carefully read the question and answer accordingly.


Identify the below statement:

STATEMENT A : In Oracle 10g the default action of a DROP TABLE


command is to move the table to the recycle bin (or rename it), rather
than actually dropping it.
STATEMENT B: PURGE option can be used to permanently drop a Both statement A and B are
table. True.

Carefully read the question and answer accordingly.


SELECT e.EMPLOYEE_ID,e.LAST_NAME,e.DEPARTMENT_ID,
d.DEPARTMENT_NAME
FROM EMP e, DEPARTMENT d
WHER e.DEPARTMENT_ID = d.DEPARTMENT_ID;

In the statement, which capabilities of a SELECT statement are


performed? Selection, Projection, Join
You can join a maximum of
Carefully read the question and answer accordingly. two tables through an
What is true about joining tables through an equijoin? equijoin.

Carefully read the question and answer accordingly.


John wants to see how many employees are there whose salary is Select count(*) from emp
above average. where sal > (select max(sal)
Which of the following query will help john to achieve this task? from emp);

Carefully read the question and answer accordingly.


John wants to retrieve all the employee details whose Employee select empName , empNo
Number matches to any of the Department Number. Help john to from emp where empno =
achieve his task ( select deptNo from dept)

Carefully read the question and answer accordingly.


An outer join returns all rows that satisfy the join condition and those
rows from one table for which no rows from the other satisfy the join
condition.
State True or False. TRUE

Carefully read the question and answer accordingly.


Which of the Following Statements are true?
Statement A : Join permanently joins two tables having 1 or more
common attributes Statement A is true and B is
Statement B: Inner Joins are also called as EQUI Joins false.
Carefully read the question and answer accordingly. Both tables have NULL
In which case should you use a FULL OUTER JOIN? values.

Carefully read the question and answer accordingly.


Identify the type of join used in the below query
SELECT empName,DeptNo,DeptName
FROM Emp, Dept
WHERE Emp.DeptId >Dept.DeptId Equi Join

Carefully read the question and answer accordingly.


Which of the following statements are true ?
Statement A: The ANY operator compares the main query with any of
the values returned by the inner query.
Statement B: The ALL operator compares a value to every value Statement A is true and B is
return by the sub query. false.

Carefully read the question and answer accordingly.


Which of the following is the correct syntax for left outer join ?
1.select Stud_Name , clg_Name
from student s left outer join college c
on s.clg_code = c.clg_code
2.select Stud_name , clg_Name
from studentDemo s ,collegeDemo c
where s.clg_code = c.clg_code(+)
3.select Stud_name , clg_Name
from studentDemo s ,collegeDemo c
where s.clg_code(+) = c.clg_code
4.select Stud_Name , clg_Name
from student s outer join left college c
on s.clg_code = c.clg_code
5.select Stud_Name , clg_Name
from student s left outer join college c
where s.clg_code = c.clg_code 1&2
Carefully read the question and answer accordingly.
Which two statements are true regarding the USING clause in table
joins?
1. It can be used to join a maximum of three tables.
2. It can be used to restrict the number of columns used in a
NATURAL join.
3. It can be used to access data from tables through equijoins as well
as nonequijoins.
4. It can be used to join tables that have columns with the same name
and compatible data types. 1&2

Carefully read the question and answer accordingly.


What's the result of the following concatenation
'apple' || NULL || NULL || 'sauce' apple sauce

Carefully read the question and answer accordingly. IN Parameter is the default
Which statements are true about IN parameter? parameter.

The EXIT-WHEN statement


Carefully read the question and answer accordingly. lets a loop complete
What is an EXIT - WHEN statement? unconditionally.

Carefully read the question and answer accordingly.


Which of the values can be assigned to a Boolean variable ? TRUE

We can use the %TYPE


attribute as a datatype
specifier when declaring
Carefully read the question and answer accordingly. constants, variables, fields,
What is meant by %Type? and parameters.

Carefully read the question and answer accordingly.


You must declare each variable of same data type separately TRUE
Carefully read the question and answer accordingly.
Pick the advantage of declaring a variable using %TYPE attribute. For
example: you need not know the
v_last_name employees.last_name%TYPE. exact datatype of last_name

Carefully read the question and answer accordingly.


Fields in a %ROWTYPE record inherit constraints TRUE

Carefully read the question and answer accordingly.


Identify the code snippet
declare EmpNAME;
begin
SELECT ENAME INTO EmpNAME FROM Emp WHERE
EmpNo=101172;
dbms_output.put_line(EmpName); Employee name whose
end; employee no is 101172 is
what will be the output of the above code printed

Carefully read the question and answer accordingly.


Predict the value of variable named "B" ?
DECLARE
A BOOLEAN := NULL;
B BOOLEAN;
BEGIN
B := A IS NULL;
IF B IS NULL THEN
DBMS_OUTPUT.PUT_LINE('HI');
END IF;
END; TRUE

Carefully read the question and answer accordingly.


State True or False,
What are the two types of conversion between datatypes?
1)Explicit datatype conversion
2)Implicit datatype conversion TRUE

Carefully read the question and answer accordingly.


PL/SQL treats any zero-length string as _______ blank space

Carefully read the question and answer accordingly.


In conditional control statements, if the condition yields NULL, its
associated sequence of statements is not executed TRUE
Carefully read the question and answer accordingly.
Which of the following statements are true?
1.A PL/SQL block has three parts, declarative part, an executable part
and an exception handling part.
2.Declarative and Executable block are Mandatory
3. A PL/SQL Block can be anonymous or named
4. Identifiers in PL/SQL can contain max 35 character
5. Blocks of PL/SQL statements are translated by the PL/SQL engine
that can reside either in the client or at the server side. 1&2

Carefully read the question and answer accordingly.


DECLARE
v_boolean BOOLEAN;
BEGIN
v_boolean := 'TRUE';
DBMS_OUPUT.PUT_LINE(v_boolean);
END;
Predict the output of the program ? TRUE

Carefully read the question and answer accordingly.


How to display output from PLSQL? DBMS_OUTPUT.PUT_LINE

Carefully read the question and answer accordingly. %TYPE variables do not
Pick the CORRECT statement about %TYPE variables inherit NOT NULL
such as the NOT NULL or or default values constraints

Carefully read the question and answer accordingly.


Identify the code snippet
DECLARE
var_num1 number:=50;
var_num2 number;
BEGIN
var_num2 := 200;
DECLARE
var_mult number;
var_num1 number:= 100; -- LINE 1
BEGIN
var_mult := var_num1 * var_num2;
END;
dbms_output.put_line( var_num1);
END;
/
what will be the output of the above code assume serveroutput is on Runs without any output
Carefully read the question and answer accordingly.
In Oracle PL/SQL by default, variables are initialized to NULL. TRUE

Carefully read the question and answer accordingly.


The %ROWTYPE attribute provides a record type that represents a
row in view

Returns NULL if the cursor


Carefully read the question and answer accordingly. is open but fetch has not
What are the true aspects about the %NOTFOUND attribute? been executed.

Carefully read the question and answer accordingly. A Default index is created in
In SQL, which of the following is NOT true with respect to Primary the column which acts as a
Key? Primary key.

Carefully read the question and answer accordingly.


Identify the type of variable declared
VARIABLE City Varchar2(20). Bind Variable

Carefully read the question and answer accordingly.


Which is called as index-by tables ? Nested tables

Carefully read the question and answer accordingly.


If the declaration is Number (4,5) and the assigned value is
123.4567 , what is the stored value? Error , exceeds precision

Carefully read the question and answer accordingly.


Consider the following statements that describes a PL/SQL Block
Structure:
Statement1: Declare and Exception Sections are mandatory.
Statement2: Begin and End Sections are optional. Statement1 and Statement2
Which of the following is applicable for above? are true.
Carefully read the question and answer accordingly.
Examine the code snippet
DECLARE Num Number;
BEGIN
Num:=10;
DECLARE
Num Number; --LINE 1
BEGIN
Num:=12;
while(Num<13)
loop
dbms_output.put_line(Num);
Num:=Num+1;
END loop;
END;
if Num < 12 --LINE 2
then
dbms_output.put_line('Less');
end if;
END;
/ Compilation fails due to
What will be the result of the above code? error on line 1

The CASE statement


selects one sequence of
statements to execute. To
select the sequence, the
CASE statement uses a
selector rather than multiple
Boolean expressions. A
selector is an expression
whose value is used to
Carefully read the question and answer accordingly. select one of several
What is meant by case statements in PLSQL? alternatives

Carefully read the question and answer accordingly.


The patterns matched by LIKE can include two special-purpose
characters called wildcards. _(underscore)

Carefully read the question and answer accordingly.


Comparisons involving nulls always yield NULL TRUE

A package specification can


Carefully read the question and answer accordingly. exists without a package
What are the true aspects of PLSQL? body
Carefully read the question and answer accordingly. max_days_in_year
Pick the valid constant declaration in PL/SQL CONSTANT INTEGER;

Carefully read the question and answer accordingly. Value before change (:OLD)
What will be the old and new value of a database column before : Null Value After change
AFTER and DELETE operation? (:NEW) : Null

A GOTO statement cannot


transfer control into an IF
statement, CASE
Carefully read the question and answer accordingly. statement, LOOP
What are the restrictions of GO TO statements? statement, or sub-block.

The EXIT statement forces


Carefully read the question and answer accordingly. a loop to complete
What does an EXIT statement do in PLSQL? unconditionally

Carefully read the question and answer accordingly.


You cannot assign nulls to a variable defined as NOT NULL. If you try,
PL/SQL raises the predefined exception _________ STORAGE_ERROR

Carefully read the question and answer accordingly.


Which of the following statement is TRUE
(i) Strong REF CURSOR types are less error prone
(ii) Weak REF CURSOR types are not flexible (i)

Carefully read the question and answer accordingly.


Which of the following logically related components can be grouped in
a PL/SQL package ? PL/SQL types

Carefully read the question and answer accordingly.


A PL/SQL function can return more than one value from a function
using PL/SQL record or PL/SQL table TRUE

Carefully read the question and answer accordingly. The SELECT list or clause
User-defined PL/SQL functions can be used in of a query
Carefully read the question and answer accordingly.
which parameter passing mode passes a value from the calling
environment to the procedure and a possibly different value from the
procedure back to the calling environment using the same
parameter ? IN

Carefully read the question and answer accordingly.


Which of the following sections can be present in an anonymous
PL/SQL block? Declaration

ALTER TABLE emp ADD


Carefully read the question and answer accordingly. CONSTRAINT ck_sal
Which code can you use to ensure that the salary is not increased by CHECK (sal BETWEEN sal
more than 10% at a time nor is it ever decreased? AND sal*1.1);

Carefully read the question and answer accordingly.


what is the result when we attempt to change the value of an IN
parameter ? run time exception

Carefully read the question and answer accordingly.


CREATE OR REPLACE FUNCTION dml_call_sql(sal NUMBER)
RETURN NUMBER IS
BEGIN
INSERT INTO employees(employee_id, last_name,
email, hire_date, job_id, salary)
VALUES(1, 'Frost', 'jfrost@company.com',
SYSDATE, 'SA_MAN', sal);
RETURN (sal + 100);
END;
The above user defined PL/SQL function is called from the below
UPDATE query. What is your prediction about the OUTPUT ?
UPDATE employees
SET salary = dml_call_sql(2000)
WHERE employee_id = 170; UPDATE will happen
Carefully read the question and answer accordingly.
A package specification can exist without a package body; that is,
when the package specification does not declare subprograms a body
is not required TRUE

Carefully read the question and answer accordingly.


There exists a procedure called add_dept with two parameters. The
procedure is called as shown below
EXECUTE add_dept ('ADVERTISING', loc => 1200)
What type of parameter-passing is this ? positional

Carefully read the question and answer accordingly.


All the named parameters should precede the positional parameters
in a subprogram call. TRUE

Carefully read the question and answer accordingly.


You need to create a trigger on the EMP table that monitors every
row that is changed and places this information into the
AUDIT_TABLE. FOR EACH ROW trigger on
What type of trigger do you create? the EMP table.

Carefully read the question and answer accordingly.


Which two statements about packages are true?
1.Packages can be nested.
2.You can pass parameters to packages.
3.A package is loaded into memory each time it is invoked.
4.The contents of packages can be shared by many applications.
5. You can achieve information hiding by making package constructs
private. 1&2

Carefully read the question and answer accordingly.


Under which two circumstances do you design database triggers?
1.To duplicate the functionality of other triggers.
2. To replicate built-in constraints in the Oracle server such as primary
key and foreign key.
3.To guarantee that when a specific operation is performed, related
actions are performed
4.For centralized, global operations that should be fired for the
triggering statement, regardless of which user or application issues
the statement. 1&2
Carefully read the question and answer accordingly.
The functions used in SQL statements should not
use OUT or IN OUT mode parameters TRUE

Carefully read the question and answer accordingly.


Consider the following code segment :
DECLARE
TYPE first_rectype IS RECORD (
var1 VARCHAR2(100) := 'Hello World');
first_rec first_rectype;
TYPE second_rectype IS RECORD
(nested_rec first_rectype := first_rec);
second_rec second_rectype;
Begin
// ----line1
End dbms_output.put_line(secon
Which of the following statement can be fitted at ----line1? d_rec);

Carefully read the question and answer accordingly.


What part of a database trigger determines the number of times the
trigger body executes? Trigger type

Carefully read the question and answer accordingly.


For the parameters of the PL/SQL procedures, which cannot be
specified ? length of the parameter

PL/SQL procedure Can


Carefully read the question and answer accordingly. contain a RETURN
Pick the VALID statement about PL/SQL procedure ? statement without a value

Carefully read the question and answer accordingly.


Which are VALID statement about PL/SQL package ? Package body is optional

Carefully read the question and answer accordingly.


When calling a function in a SQL statement which parameter notation
must be used ? positional

Carefully read the question and answer accordingly. ALTER TRIGGERS ON


You need to disable all triggers on the EMPLOYEES table. Which TABLE employees
command accomplishes this? DISABLE;

Carefully read the question and answer accordingly.


what are the data dictionary views? ALL_SOURCE
Carefully read the question and answer accordingly.
What is the sequence of output of the following code?
DECLARE
TYPE list_of_names_t IS TABLE OF emp.ename%TYPE
INDEX BY BINARY_INTEGER;
family_mem list_of_names_t;
l_row BINARY_INTEGER;
BEGIN
family_mem (100) := 'Veena';
family_mem (-15) := 'Sheela';
family_mem (-30) := 'Syed';
family_mem (88) := 'Raji';
l_row := family_mem.FIRST;
WHILE (l_row IS NOT NULL)
LOOP
DBMS_OUTPUT.put_line ( family_mem(l_row));
l_row := family_mem.NEXT (l_row);
END LOOP;
END; Veena, Syed,Sheela,Raji

Carefully read the question and answer accordingly.


A procedure containing a single OUT parameter would be better
rewritten as a function returning the value. TRUE

Functions called from: • A


Carefully read the question and answer accordingly. SELECT statement cannot
Which are TRUE about calling a function from SQL expressions ? contain DML statements

Carefully read the question and answer accordingly.


The functions can return PL/SQL specific data types such as
BOOLEAN, RECORD, or TABLE TRUE

Carefully read the question and answer accordingly.


You have a row level BEFORE UPDATE trigger on the EMP table.
This trigger contains a SELECT statement on the EMP table to ensure
that the new salary value falls within the minimum and maximum
salary for a given job title. What happens when you try to update a The trigger fires
salary value in the EMP table? successfully.

Carefully read the question and answer accordingly.


Which parameter mode can be used to assign a default value in the
formal parameter declaration ? IN OUT
Carefully read the question and answer accordingly.
The parameters for procedures can be specified using ? an explicit data type

Carefully read the question and answer accordingly.


What exception is raised when the user enters the ID as -6 in the
below code?
DECLARE
c_id customers.id%type := &cc_id;
c_name customers.name%type;
c_addr customers.address%type;
-- user defined exception
ex_invalid_id EXCEPTION;
BEGIN
IF c_id <= 0 THEN
RAISE ex_invalid_id;
ELSE
SELECT name, address INTO c_name, c_addr
FROM customers
WHERE id = c_id;
END IF;
EXCEPTION
WHEN ex_invalid_id THEN
dbms_output.put_line('ID must be greater than zero!');
WHEN no_data_found THEN
dbms_output.put_line('No such customer!'); NO DATA FOUND
END; / exception will be raised

Carefully read the question and answer accordingly.


You are developing a trigger which should ensure that no negative
value is inserted in employee table’s Age column . you have created
a trigger as follows
create or replace trigger AgeVerify
before insert
on employee for each row
when(new.EmpAge < 0)
begin
RAISE_APPLICATION_ERROR(-20000, 'no negative age allowed'); The order of Arguments
end; passed to
/ RAISE_APPLICATION_ER
Identify error if any in the above trigger and give the solution. ROR is wrong
Carefully read the question and answer accordingly.
What is the syntax of Function?
CREATE [OR REPLACE] FUNCTION function_name [parameters]
IS
Declaration_section
RETURN return_datatype;
BEGIN
Execution_section
Return return_variable;
EXCEPTION
exception section
Return return_variable;
END; TRUE

Carefully read the question and answer accordingly.


Consider you are creating a cursor,Choose the correct sequence of Open , Declare , Fetch
steps to work with cursors? Close

Comparison operators
cannot be used to test
Carefully read the question and answer accordingly. cursor variables for equality,
What are the restrictions of REF cursor in PLSQL? inequality, null, or not null.

Carefully read the question and answer accordingly. Opening the cursor
What occurs when a cursor is opened? allocates the memory first.

When we issues a
SELECT.. FOR UPDATE
clause the RDBMS will
automatically place a locks
Carefully read the question and answer accordingly. on the all the rows identified
What is FOR UPDATE clause in Cursors? by the select statement.

Carefully read the question and answer accordingly.


The following Block of statement is written to check the manager for
each employee
declare
cursor c1 is
select ename , Mgr
from Emp;
begin
for rec in c1 LOOP
dbms_output.put_line('Employee '||rec.ename||' Works for '||rec.Mgr);
end loop; The above code has no
end; error and gives the desired
Identify errors if any in the above code and provide suitable solution result
create or replace procedure
prcEmp_details(EmpName
varchar2) as begin declare
cursor c1 is select * from
Emp where
Ename=EmpName; begin
Carefully read the question and answer accordingly. for rec in c1 LOOP
You are creating a procedure which accepts the employee name and dbms_output.put_line(rec.e
displays the employee details like Employee Name, Employee No, name||’ ’||rec.empNO||’ ’||
Manager rec.Mrg); end loop; end;
Identify the correct syntax to achieve the desired result. end;

Carefully read the question and answer accordingly.


How to convert the following code using the cursor FOR LOOP?
DECLARE DECLARE CURSOR
CURSOR occupancy_cur IS occupancy_cur IS SELECT
SELECT pet_id, room_number pet_id, room_number
FROM occupancy WHERE occupied_dt = SYSDATE; FROM occupancy WHERE
occupancy_rec occupancy_cur%ROWTYPE; occupied_dt = SYSDATE;
BEGIN occupancy_rec
OPEN occupancy_cur; occupancy_cur
LOOP %ROWTYPE; BEGIN FOR
FETCH occupancy_cur INTO occupancy_rec; occupancy_rec IN
EXIT WHEN occupancy_cur%NOTFOUND; occupancy_cur LOOP
update_bill (occupancy_rec.pet_id, occupancy_rec.room_number); update_bill
END LOOP; (occupancy_rec.pet_id,
CLOSE occupancy_cur; occupancy_rec.room_numb
END; er); END LOOP; END;

DECLARE exception_name
EXCEPTION
EXCEPTION_INIT
PRAGMA
(exception_name ,
err_code); Begin Execution
section Exception WHEN
Carefully read the question and answer accordingly. exception_name THEN
What is the syntax of PRAGMA EXCEPTION_INIT? Handle the exception END;
Implicit cursors are
automatically created by
oracle when a select query
in PLSQL is executed.
Explicit cursors is explicitly
Carefully read the question and answer accordingly. attached to a select query
What are the true aspects of implicit and explicit cursors? by programmer.

Carefully read the question and answer accordingly.


Examine the PL/SQL Block
declare
result Number;
num1 Number:=&number1;
num2 Number:=&number2;
begin
select num1/num2 into result from dual;
dbms_output.put_line('Result is '||result);
exception
when ZEROS_DIVIDE then
dbms_output.put_line('Exception Occurred Divide by Zero');
end;
/
What will be the output of the above code when user passes the value Exception Occurred Divide
for NUM1 as 0 and NUM2 as 10 by Zero

Carefully read the question and answer accordingly.


General Syntax for coding exception
DECLARE
Declaration Section
BEGIN
Exception Section
When ex_name 1 THEN
Error handling Statements
When Others THEN
Error handling Statements
When ex_name 1 THEN
Error handling Statements
END; TRUE

A group of related data


items stored in fields , each
Carefully read the question and answer accordingly. fields has its own name and
Select the best definition for Why Collection needed in Oracle? datatype.
Carefully read the question and answer accordingly.
Which of the following statements are true?
1.A collection is an ordered group of elements, all of the same type
2.Each element in collection has a unique subscript that determines
its position in the collection.
3.A collection is a ordered group of elements of different types
4.Records are composite types that have internal components that
can be manipulated individually
5.Nested Table is also known as associative arrays 1&2

Carefully read the question and answer accordingly.


Which of the following statements are true?
Statement A: Index by Table is Also known as associative arrays. It
lets you to look up elements using arbitrary numbers and strings for
subscript values.
Statement B: Nested tables hold an arbitrary number of elements. Both statements A and B
They use sequential numbers as subscripts. are False.

In a program all the


columns of a table needs to
Carefully read the question and answer accordingly. be referenced,stored and
In which case we will use Custom record? processed.

Carefully read the question and answer accordingly.


Examine the code snippet
declare
TYPE CITY is TABLE of varchar2(20) index by PLS_INTEGER;
v1 CITY;
begin
v1(1):='Bangalore';
v1(6):='Mumbai';
v1(2):='Delhi';
dbms_output.put_line(v1.count());
dbms_output.put_line(v1(2));
dbms_output.put_line(v1.next(6));
end;
what will be the output of the above code? Compilation error
Carefully read the question and answer accordingly.
Which of the following statements are true?
1.Index by table has key value pair
2.Nested Table has key value pair
3.Index by Table is ordered based on its Key
4.Nested Table id ordered based on its key
5.In a key value pair key is unique 1&2

Carefully read the question and answer accordingly.


Examine the code snippet
declare
TYPE XYZ is VARRAY(10) of NUMBER;
v2 XYZ; --line 1
x Number:=0;
Begin
v2:=XYZ(1,2,3,4,5,6,7); --line 2
v2.delete(1); --line 3
while x < v2.last –line 4
loop
x:=x+1;
dbms_output.put_line(x);
end loop;
end;
/ Compilation fails due to
What will be the output of the above code ? error on line 1

Carefully read the question and answer accordingly.


Examine the code snippet
declare
TYPE XYZ is VARRAY(10) of NUMBER;
v2 XYZ; -- line 1
x Number:=0;
Begin
v2:=XYZ(1,2,3,4,5,6,7);
v2.trim(1);--Line 2
while x < v2.last
loop
x:=x+1;
dbms_output.put_line(x);
end loop;
end;
/ Compilation fails due to an
What will be the output of the above code? error on line 1
Carefully read the question and answer accordingly.
DECLARE
TYPE StockItem IS RECORD(
item_no Item_master.Item_code%TYPE,
item_name Item_master.Item_name%TYPE,
quantity Stock.Current_stock%TYPE,
Unit_price Item_master.unit_price%TYPE);
St_rec StockItem;
Predict what type of record it fall under ? Table Record

Carefully read the question and answer accordingly.


Predict which collection has ability to have elements selected
Individually in database. Varray

Carefully read the question and answer accordingly.


Examine the code snippet
declare
TYPE ABC is VARRAY(10) of NUMBER;
v2 ABC;
begin
v2:=ABC();
v2.extend();
v2(1):=78;
Dbms_output.put_line(v2(1));
end; Code contains a compilation
what will be the output of the above code ? error

Carefully read the question and answer accordingly.


Examine the code snippet
declare
TYPE ABC is VARRAY(10) of NUMBER;
v2 ABC:=ABC(10,8,9,6,5,4,3,32);
begin
Dbms_output.put_line(v2(1));
end;
what will be the output of the above code ? Compilation fails

Carefully read the question and answer accordingly.


Which of the following statements are true?
Statement A : Arrays have a fixed upper bound, but nested tables are
unbounded
Statement B : Second, arrays must have consecutive subscripts and
nested tables are dense, but they can be sparse (have non- Both statements A and B
consecutive subscripts). are False.
Carefully read the question and answer accordingly.
Which of the following statements are true
Statement A :The body of the FORALL statement must contain a
single DML operation.
Statement B: The EXECUTE IMMEDIATE statement prepares
(parses) and immediately executes a dynamic SQL statement or an Both statements A and B
anonymous PL/SQL block. are False

Carefully read the question and answer accordingly.


Predict which collection has ability to preserve element order. Nested Table

Carefully read the question and answer accordingly.


IF add_genre_new THEN
IF NOT fic_genres.EXISTS(f_genre_id) THEN
fic_genres.EXTENDS(1); 1. Add a new genre. 2. Is
fic_genres(f_genre_id) := f_genre; this genre id already in the
DBMS_OUTPUT.PUT_LINE('Total # of entries in fiction_genres is : collection? 3. Display the
'||fiction_genres.COUNT(); total # of elements. 4.
END IF; **Add** another element to
Predict the correct steps of the above code ? the varray.

Carefully read the question and answer accordingly.


HTML is used to perform the programming logic.
State True or False. FALSE

Carefully read the question and answer accordingly.


Which of the following is an empty tag in HTML? <a>

Carefully read the question and answer accordingly.


ALT' attribute in <IMG> tag used to represents Image filename

Which represents the


Carefully read the question and answer accordingly. content to be displayed in
What is the use of attributes in HTML tags? the page

Carefully read the question and answer accordingly.


Which tag is used to include multiple HTML pages in single page? frame

Carefully read the question and answer accordingly.


How to divide the page into two rows when we are using frameset? By using cols=50%,50%
Carefully read the question and answer accordingly.
How to divide the page into two equal halves when we are using
frameset ?
1.By using cols=50%,50%
2.By using rows=50%,50%
3.By using colspan
4.by using rowspan 1&2

Carefully read the question and answer accordingly.


The below html meta tag will reload page automatically every 60
______ .
<meta http-equiv="refresh" content="60"> seconds

Carefully read the question and answer accordingly.


Which of the following is not an attribute of meta tag? content

Carefully read the question and answer accordingly.


Automatic page Refresh can be done by using refresh Meta Tag.
State True or False. TRUE

Carefully read the question and answer accordingly.


Which of the following are the functions of caching?
1.Temporarily storing the web page in the client
2.Reduce the network traffic
3.Decrease the speed of the response
4.Increase the speed of the response 1&2

Carefully read the question and answer accordingly.


Consider Vijay is developing web page using HTML.Which method he
can use for sending data securely on submitting the form?
I: POST
II: GET I

Carefully read the question and answer accordingly.


Consider Vijay is developing web page using HTML.Which method he
can use for sending large amount of data on submitting the form?
I: POST
II: GET I

Carefully read the question and answer accordingly.


Consider Vijay is developing web page using HTML. He wants user
to enter some data which is multiline data. What must be the form
element or control to be used by him? TextBox
Carefully read the question and answer accordingly.
Which tag creates containers to other HTML tags/elements?
I: DIV
II: SPAN I

Carefully read the question and answer accordingly.


Which tag is used if we want to apply same styles for a block of
elements?
I: DIV
II: SPAN I

Carefully read the question and answer accordingly.


If we want to apply a style for a text or a part of a text which tag will be
used?
I: SPAN
II: DIV I

Carefully read the question and answer accordingly.


DIV tag creates linebreaks similar to paragraph tags.
State True or False. TRUE

Carefully read the question and answer accordingly.


Which of the following are valid variable declarations in Java Script?
1.var x=3.14
2.var int x=4;
3.var x=4;
4.var country="INDIA" 1&2

Carefully read the question and answer accordingly.


Which of the following are valid identifiers in Java Script?
1._num
2.num
3.9char
4.$num 1,2&4

Carefully read the question and answer accordingly.


Variables in Java Script should be declared with data types.
State True or False. FALSE

Carefully read the question and answer accordingly.


Which of the following are used for executing client side script?
1.JavaScript
2.JSP
3.Servlets
4.VBScript 1&2

Carefully read the question and answer accordingly.


Please select the correct statement with respect to including JavaScript can be written
JavaScript in HTML pages. inside the page body
Carefully read the question and answer accordingly.
In JavaScript, for accessing first paragraph tag in the document which document.getElementsByTa
of the statement is used? gName("p")[0]

Carefully read the question and answer accordingly.


In JavaScript, for reading the contents inside the first paragraph tag document.getElementsByTa
which statement is used? gName("p").innertext()

Carefully read the question and answer accordingly.


Consider Vijay is developing a web application. Which method he can
use to get a collection of elements of same type (for example
paragraph tags) in Java Script? getElementByName()

Carefully read the question and answer accordingly.


What will be the output of the following Java Script code when the
button is clicked?
<body>
<script type="text/javascript">
function displayMessage(){
document.write("Displaying message by using javaScript");
}
</script>
<button type="button" It will print the message
Message</button> "Displaying message by
</body> using javaScript"

Carefully read the question and answer accordingly.


What is the correct syntax of the declaration which defines the XML
version? <xml version="1.0" />

Carefully read the question and answer accordingly. <! ELEMENT element-
How to declare element with minimum one occurrence? name(element-content+)>

Carefully read the question and answer accordingly. <message> if


Which of the following XML statement is valid? price<60</message>

Carefully read the question and answer accordingly.


What does DTD stands for? Direct Type Definition

Carefully read the question and answer accordingly. DTD are used by parsers for
Which of the following correctly defines use of DTD in XML validating the structure of
development? the XML
Carefully read the question and answer accordingly.
Any text that should not be parsed by the xml parser needs to declare
as:
I: PCDATA
II: CDATA I

Carefully read the question and answer accordingly.


What does XML stand for? eXtra Modern Link

Carefully read the question and answer accordingly.


Which parser is a W3C standard? SAX

Carefully read the question and answer accordingly.


What are the uses of XML parsers?
1.Parsing XML files and retrieving data from XML elements
2.Creating XML files programmatically
3.Used to direct conversion using an XSLT processor 1&2

Carefully read the question and answer accordingly.


Which parser reads small chunk of document at a time,parses it,
generate an events and then reads another chunk of document DOM

Carefully read the question and answer accordingly.


Which defines standard set of objects for creating XML's? SAX

Carefully read the question and answer accordingly.


Which type of parser is suitable,when applications is required to read
data without modifying the content DOM

Carefully read the question and answer accordingly. DocumentBuilder b=new


Which statement creates DocumentBuilder instance? DocumentBuilder();

Carefully read the question and answer accordingly. Extensive Style sheet
What does XSL stands for? language

DocumentBuilderFactory
Carefully read the question and answer accordingly. f=new
Which statement creates DocumentBuilderFactory instance? DocumentBuilderFactory();

Carefully read the question and answer accordingly.


Which language is used for formatting XML documents? XSL

Carefully read the question and answer accordingly.


Which is used to transform XML document? Xpath
Carefully read the question and answer accordingly.
What are the two common exceptions in JAXP?
1.ParserConfigurationException
2.FactoryConfigurationException
3.FactoryConfigurationError 1&2

Carefully read the question and answer accordingly. Java API eXtensive
JAXP Stands for: processing

Carefully read the question and answer accordingly.


In which package JAXP related API's are available? javax.xml.parsers.*;

<xs:complexType
name="CountrInfo"><xs:all>
<xs:element
name="countryName"
type="xs:string"/>
Carefully read the question and answer accordingly. <xs:element name="states"
Which complex type specifies that the elements should always be in type="xs:integer"/></xs:all>
the order specified? </xs:complexType>

<xs:element
name="CountryName"
Carefully read the question and answer accordingly. type="xs:string"
Which statement specifies a constant value for a simple element? constant="India"/>

<xs:complexType
name="CountrInfo"><xs:all>
<xs:element
name="countryName"
type="xs:string"/>
Carefully read the question and answer accordingly. <xs:element name="states"
Which complex type signifies that only one of the child elements can type="xs:integer"/></xs:all>
appear? </xs:complexType>

Carefully read the question and answer accordingly.


As per Java coding standard class names should be nouns, in mixed
case
with the first letter of each internal word capitalized.
Try to keep your class names simple
and descriptive.
State True or False. TRUE
Carefully read the question and answer accordingly.
Select the right coding best practices followed while using java
Collections.
1.Use for loop instead of iterator
2.Use Collections with generic with same type of data.
3.Copy collections into other collections by calling addAll() methods
instead using iterator to copy each collection element. 1&2

Carefully read the question and answer accordingly.


Consider the following code snippet:
import org.junit.*;
import static org.junit.Assert.*;
import java.io.*;
public class OutputTest {
private File output;
@Before
public void createOutputFile() {
output = new File(...);
}
@After
public void deleteOutputFile() {
output.delete();
}
@Test
public void testSomethingWithFile() {
...
}
} createOutputFile()
Which of the following option gives the order in which the methods in deleteOutputFile()
the above given OutputTest class is executed? testSomethingWithFile()

Carefully read the question and answer accordingly.


Select correct naming convention used during class declaration.
1.Class name should be nouns
2.Should be simple & descriptive
3.Class name starts with lower case.
4.Class name can be java valid keyword. 1&2

Carefully read the question and answer accordingly.


Documentation comments are meant to describe the specification of
the code to be read by developers.
State True or False. TRUE

Carefully read the question and answer accordingly.


Which tool verifies for best practice adherence?
1.PMD
2.Check Style
3.CPD
4.ANT 1&2
Carefully read the question and answer accordingly.
What are the major areas PMD tool scans java code? Coding standards

Carefully read the question and answer accordingly.


Which of the following is build tool? ANT

Carefully read the question and answer accordingly.


Choose a valid package name in Java?
1.com.sun.eng
2.123pack
3.pack123
4.outerpack_innerpack 1&2

Carefully read the question and answer accordingly.


Select the advantages of using coding conventions in java application Improves Readability of the
development. software

Carefully read the question and answer accordingly.


public class MethodSigExample
{
public int test(String s, int i)
{
int x = i + s.length();
return x;
}
}
Refactor > Change Method
During refactoring method signature can be changed using the option: Signature

Carefully read the question and answer accordingly.


What are the types of refactoring?
1.Physical Structure
2.Logical Structure
3.Method Level
4.Class Level Structure 1&2

Carefully read the question and answer accordingly.


What are the Tools & plug-ins commonly used in testing java
application code?
1.ANT
2.JUnit
3.JavaScript
4.EMMA 1&2

Carefully read the question and answer accordingly.


What are the benefits of Logging?
1.Debug applications issues easily
2.Detect complier errors easily
3.Trouble Shoot performance problems 1&2
Carefully read the question and answer accordingly.
Select the benefits of versioning the software in java application
development.
1.Backup and Restore
2.WinZIP
3.Synchronization
4.Branching and merging
5.Formatting 1&2

Carefully read the question and answer accordingly.


An art of identifying, organizing, controlling and verifying the
modification to the software work products built by the developer. SDLC

Carefully read the question and answer accordingly.


Which of these is executed first before execution of any other thing
takes place in a program? main method

By multithreading CPU’s
idle time is minimized, and
Carefully read the question and answer accordingly. we can take maximum use
Which of the following statement is incorrect? of it.

Carefully read the question and answer accordingly.


Consider a development scenario where you want to write the object
data into persistence storage devices (like file, disk etc.).Using which
of the below concept you can achieve the given requirement? finalization

Carefully read the question and answer accordingly.


In Thread implementation making method synchronized is always
better in order to increase application performance rather than using
synchronize block to synchronize certain block of statements written
in java inside the method.
State True or False. FALSE

Carefully read the question and answer accordingly.


Consider you are developing an application where you have to store
and retrieve data in character format in file. Which API you will use to Reader and Writer Stream
store and retrieve the data in character format? APIs
Carefully read the question and answer accordingly.
Consider you are developing a JDBC application, where you have to
retrieve quarterly report from database by executing database store
procedure created by database developer. Which statement API you
will use to execute store procedure and retrieve ResultSet
information? Statement

Carefully read the question and answer accordingly. If the equals() method
Which statements are true about comparing two instances of the returns true, the hashCode()
same class, given that the comparison == might return
equals() and hashCode() methods have been properly overridden? false

Generics provide type


Carefully read the question and answer accordingly. safety by shifting more type
Which of the following is incorrect statement regarding the use of checking responsibilities to
generics and parameterized types in Java? the compiler.

Carefully read the question and answer accordingly.


Which collection class allows you to grow or shrink its size and
provides indexed access to its elements, but whose methods are not
synchronized? java.util.HashSet

Carefully read the question and answer accordingly.


Consider you are developing an ATM application for ABC Bank using
java application. Several account holders of ABC Bank have opted for
add-on cards. There is a chance that two users may access the same
account at same time and do transaction simultaneously knowingly or
unknowingly from different ATM machine from same or different bank
branches. As developer you have to ensure that when one user login
to account until he finishes his transaction account should be locked
to other users who are trying access the same account. How do you Using Thread
implement given requirement programmatically using java? Synchronization
Carefully read the question and answer accordingly.
Consider you are developing a JDBC application, where you have to
retrieve the Employee information from the database table based on
Employee id value passed at runtime as parameter. Which best
statement API you will use to execute parameterized SQL statement
at runtime? Statement

Carefully read the question and answer accordingly.


You need to store elements in a collection that guarantees that no
duplicates are stored and all elements can be accessed in natural
order. Which interface provides that capability? java.util.Map

Carefully read the question and answer accordingly.


Consider you are developing shopping cart application you have to
store details of items purchased by the each customer in intermediate
memory before storing purchase details in actual database
permanently note that number of different items purchased by
customer is not definite it may vary. How do you implement given
requirement using java considering best performance of the
application? Implement using Arrays

Carefully read the question and answer accordingly.


Consider you are developing a JDBC application, where you have to
retrieve Employee table schema information like table columns name,
columns field length and data type etc. Which API you will use to
retrieve table schema information? ResultSet

Carefully read the question and answer accordingly.


Consider the development scenario where you have created
Employee class with implementation code and as per the project
requirement you have to ensure that developer in team reusing code
written in Employee class only using inheritance by extending the
employee class but not by creating the instance of Employee object Mark Employee class with
directly. Please suggest the solution to implement given requirement? abstract keyword
Carefully read the question and answer accordingly.
Consider you are developing java application in a team consists of 20
developers and you have been asked to develop class by Name
ProgrammerAnalyst and to ensure that other developers in team use
ProgrammerAnalyst class only by creating object and team member
should not be given provision to inherit and modify any functionality Declare the
written in ProgrammerAnalyst class using inheritance. How do you ProgrammerAnalyst class
achieve this requirement in development scenario? has abstract

Carefully read the question and answer accordingly.


What will happen if two thread of same priority are called to be Any one will be executed
processed simultaneously? first lexographically

Carefully read the question and answer accordingly.


In Thread implementation methods like wait(), notify(), notifyAll()
should be used in synchronized context .
State true or false TRUE

Carefully read the question and answer accordingly.


Which class does not override the equals() and hashCode() methods,
inheriting them directly from class Object? java.lang.String

Carefully read the question and answer accordingly.


Interfaces are mainly used to expose behavior or functionality not the
implementation code.
State true or false TRUE

Carefully read the question and answer accordingly.


Select the advantages of using Collection API’s in java application Reduces programming
development. effort

Carefully read the question and answer accordingly.


Which of the following provides an efficient means of storing key/value
pairs in sorted order, and allows rapid retrieval? TreeMap
Carefully read the question and answer accordingly.
Consider you are trying to persist or store object of Customer class
using ObjectOutputStream class in java. When you are trying to
persist customer object data java code is throwing runtime exception Check whether you have
without persisting object information. Please suggest what is the key implemented Customer
important factor you have consider in code in order to persist class with Serializable
customer object data. interface

Carefully read the question and answer accordingly.


The below procedure raises exception using
RAISE_APPLICATION_ERROR when we try to delete a department
that is not available in the below table else to diplay a message that
the department is <available> Deleted.
TABLE DATA : tbl_departments
DEPARTMENTID DESCRIPTION
20 Science
30 Economics
40 Statistics
50 History
CODE:
CREATE OR REPLACE PROCEDURE Available_Dept(P_DeptId
tbl_departments.departmentid%TYPE) IS
BEGIN
DELETE FROM tbl_departments WHERE departmentid = P_DeptId;
IF SQL%NOTFOUND THEN
RAISE_APPLICATION_ERROR (-20201, P_DeptId || ' does not
exist');
ELSE
DBMS_OUTPUT.PUT_LINE('Department details are
<Available>Deleted');
END IF;
END Available_Dept; TRUE
DECLARE TYPE EmpRec
IS RECORD ( emp_id
emp.empno%TYPE,
job_title VARCHAR2(9),
salary NUMBER(7,2));
emp_info EmpRec; BEGIN
emp_info.emp_id := 7788;
Carefully read the question and answer accordingly. emp_info.job_title :=
Which code assign null to all the fields in the record 'ANALYST'; emp_info.salary
emp_info? := 3500; END;

Carefully read the question and answer accordingly.


Join queries are better in performance than Subqueries.
State true or false. TRUE

CREATE TRIGGER
log_errors BEGIN IF
(IS_SERVERERROR
(1017)) THEN <special
Carefully read the question and answer accordingly. processing of logon error>
Which of the trigger is used to log all errors and also to do some ELSE <log error number>
special processing when the log error is 1017? END IF; END;

Carefully read the question and answer accordingly.


XYZ Company database tables are accessed by several users but
few users want to do positional row updates or deletes operation on
databases tables based on business requirement. What will the right
solution you will implement in such scenario? Use Views
Carefully read the question and answer accordingly.
Consider you are maintaining ABC company database. ABC company
database tables are accessed by 1000 users initially when it was
designed from last two years there was tremendous increase in
number records count also number of users who are accessing the
database tables to fetch results. Users of ABC company database are
reporting problem that query processing is taking more time when
they execute query against the database tables. What will the right
solution you will suggest in such scenarios in order to increase
database query performance? Create Function

CREATE OR REPLACE
PACKAGE
employee_package AS
TYPE emp_rec IS RECORD
( employeeid NUMBER,
firstname VARCHAR2(10),
lastname VARCHAR2(10),
salary NUMBER);
Carefully read the question and answer accordingly. minimum_count
Which is the valid Package specification for the below requirements. CONSTANT NUMBER := 4;
1) A procedure to update each professors salary FUNCTION get_employee
2) A function to return the professor details who receive less salary RETURN emp_rec;
compared to others. PROCEDURE
3) A REF CURSOR to be declared update_salary (employeeid
4) A employee record with employeeid , employee name , salary. IN NUMBER); END
5) A constant with datatype NUMBER with value 4 employee_package;

Faster application
development. Because the
database stores triggers,
Carefully read the question and answer accordingly. you do not have to code the
Which of the following is the benefits using triggers in database trigger actions into each
management system? database application.
Carefully read the question and answer accordingly.
What is the collection exception raised for the below code?
DECLARE
TYPE NumList IS TABLE OF NUMBER;
nums NumList;
BEGIN
nums(1) := 1; SUBSCRIPT_BEYOND_CO
END; UNT

Carefully read the question and answer accordingly.


Can the function get_employees be called in an SQL statement as
below ,
SELECT departmentid, description , get_employees(maxsalary)
"Employeeid"
FROM tbl_departments
WHERE maxsalary = 3000 TRUE

Carefully read the question and answer accordingly.


What error the following code will display?
DECLARE
dynamic_stmt VARCHAR2(200);
dummy BOOLEAN;
FUNCTION get_x (x INTEGER)
RETURN BOOLEAN
AS
BEGIN
NULL;
END get_x;
BEGIN
dynamic_stmt := 'BEGIN :b := get_x(5); END;';
EXECUTE IMMEDIATE dynamic_stmt USING OUT dummy; "Cannot string in current
END; PLSQL session"

Carefully read the question and answer accordingly.


Examine the description of the employees table:
EMP_ID NUMBER (4) NOT NULL
LAST_NAME VARCHAR2 (30) NOT NULL
FIRST_NAME VARCHAR2 (30)
DEPT_ID NUMBER (2)
JOB_CAT VARCHAR (30)
SALARY NUMBER (8, 2) SELECT dept_id, MIN
Which of the following SQL statements shows the department ID, (salary), MAX (salary)
minimum salary, and maximum salary paid in that department, only if FROM employees WHERE
the minimum salary is less than 2000 and maximum salary is more MIN(salary) < 2000 AND
than 5000? MAX (salary) > 5000
Carefully read the question and answer accordingly.
In the Student Management system we have a table called
STUDENTS, COURSES, ENROLLMENTS with below data
TABLE DATA - STUDENTS:
STUDENTID FIRSTNAME LASTNAME
10001 Francis Peter
10002 Venkat Prasad
TABLE DATA - COURSES:
COURSEID DEPARTMENTID COURSENAME
1112 20 Science
1113 30 Economics
The below procedure is used to identify the coursenames in the
department 20.
CREATE OR REPLACE PROCEDURE proc_coursename(p_deptid
IN courses.departmentid%TYPE)
AS
v_coursename VARCHAR2(10);
CURSOR c_coursename IS
SELECT coursename
FROM courses
WHERE departmentid = p_deptid;
BEGIN
FOR v_rec_coursename IN c_coursename LOOP
DBMS_OUTPUT.PUT_LINE('The course in Department ID:'||' '||
p_deptid||' '||'is'||' '||v_rec_coursename.coursename);
END LOOP;
END proc_coursename; TRUE

Carefully read the question and answer accordingly.


Views are a powerful mechanism for customizing the way your data is
presented to users. They can be used to enhance security and
streamline complex table relationships. Views that create static results
can still be modified using ________, which allow you to define how
the underlying tables are modified ensuring your data integrity. Triggers

Carefully read the question and answer accordingly.


Which error will be raised for the below code?
DECLARE
TYPE tb_numbers_nt IS TABLE OF NUMBER;
l_numbers tb_numbers_nt;
BEGIN
l_numbers.EXTEND;
l_numbers(1) := 1;
END; No error
CREATE OR REPLACE
PROCEDURE
get_Coursename(p_student
id IN
TBL_students.studentid
%TYPE) AS v_studentid
NUMBER; v_coursename
Carefully read the question and answer accordingly. VARCHAR2(10); CURSOR
In the Student Management system we have a table called c_course_name IS SELECT
STUDENTS, COURSES, ENROLLMENTS with below data co.coursename FROM
TABLE DATA - STUDENTS: TBL_students s, courses co
STUDENTID FIRSTNAME LASTNAME , enrollments e WHERE
10001 Francis Peter s.studentid = p_studentid
10002 Venkat Prasad AND s.studentid =
TABLE DATA - COURSES: e.studentid AND e.courseid
COURSEID DEPARTMENTID COURSENAME = co.courseid; BEGIN FOR
1112 20 Science v_rec_coursename IN
1113 30 Economics c_course_name LOOP
TABLE DATA - ENROLLMENTS: v_studentid := p_studentid;
COURSEID SECTION STUDENTID DBMS_OUTPUT.PUT_LINE
1112 A 10001 ('Student With ID:'||' '||
1113 B 10002 v_studentid||' '||'Major
Which PLSQL procedure is used to display the student details along Subject is'||' '||
with the course names they have enrolled. v_rec_coursename.coursen
NOTE : STUDENTID should be passed as parameter. ame); END LOOP; END
SAMPLE OUTPUT : Student with ID:10001 Major subject is Science. get_Coursename;

Carefully read the question and answer accordingly.


XYZ Company database tables are accessed by several users but for
few users need to be provided provision for updating information like
address, phone number, email address in secured manner without
providing direct access to underlying database base tables. What will
the right solution you will implement in such scenario to meet
requirement? Create Views

CREATE TABLE EMP


(empno NUMBER (4),
ename VARCHAR2 (35),
deptno NUMBER(7,2) NOT
NULL,CONSTRAINT
Carefully read the question and answer accordingly. emp_deptno_fk FOREIGN
Which of the following SQL statements defines a FOREIGN KEY KEY deptno REFERENCES
constraint on the deptno column of the EMP table? dept deptno)
CREATE OR REPLACE
PROCEDURE
Available_major(p_course
courses.coursename
%TYPE) IS v_courseid
NUMBER; v_coursename
VARCHAR2(20); v_deptid
NUMBER; BEGIN SELECT
courseid ,departmentid,
coursename INTO
v_courseid,v_deptid,v_cour
sename FROM courses
WHERE coursename like
p_course||'%';
DBMS_OUTPUT.PUT_LINE
('Course Available with
department ID:'||' '||
v_deptid); EXCEPTION
WHEN NO_DATA_FOUND
Carefully read the question and answer accordingly. THEN
Which procedure raises an exception 'NO DATA FOUND' when the DBMS_OUTPUT.PUT_LINE
student searches for the course which is not available else to display ('No Course Available');
a message that the course is available. END Available_major;
CREATE OR REPLACE
PROCEDURE
proc_get_details(p_grade
IN TBL_GRADE.grade
%TYPE) AS v_studentid
NUMBER; v_coursename
VARCHAR2(10); v_grade
NUMBER; CURSOR
c_grade IS SELECT
g.studentid, co.coursename
FROM TBL_GRADE g,
Carefully read the question and answer accordingly. COURSES co WHERE
Which procedure gets the student id and the course name for the g.courseid = co.courseid
given grade. AND g.grade = p_grade;
TABLE DATA - COURSES: BEGIN OPEN c_grade;
COURSEID DEPARTMENTID COURSENAME LOOP FETCH c_grade
1112 20 Science INTO v_studentid ,
1113 30 Economics v_coursename;
TABLE DATA - TBL_GRADE: DBMS_OUTPUT.PUT_LINE
STUDENTID COURSEID YEAR SEMESTER ('Student ID:'||' '||
GRADE v_studentid||' '||'grade is'||' '||
10001 1112 2014 'Second Semester' 1 v_grade); END LOOP;
10002 1113 2015 'First Semester' 2 CLOSE c_grade; END
SAMPLE OUTPUT : Student ID: 10001 grade is 1 proc_get_details;

Carefully read the question and answer accordingly.


How do we compare records?
(old_company_rec, new_company_rec are 2 records with name , IF old_company_rec IS
incorp_date, address1 as fields) NULL THEN -------.. END IF;
Carefully read the question and answer accordingly.
What exception the below code will raise?
DECLARE
TYPE tab_numbers IS TABLE OF NUMBER
INDEX BY PLS_INTEGER;
l_numbers tab_numbers;
BEGIN
DBMS_OUTPUT.PUT_LINE (l_numbers (100));
END; TOO_MANY_ROWS

CREATE OR REPLACE
TRIGGER salary_changes
BEFORE DELETE OR
INSERT OR UPDATE ON
TBL_EMPLOYEES FOR
EACH ROW DECLARE
sal_diff NUMBER; BEGIN
sal_diff := :NEW.salary -
:OLD.salary;
DBMS_OUTPUT.PUT(:OLD
.firstname||','||:OLD.lastnam
e|| ': ');
DBMS_OUTPUT.PUT('Old
salary = ' || :OLD.salary || ',
Carefully read the question and answer accordingly. ');
Which trigger is used to display the salary change information DBMS_OUTPUT.PUT('New
whenever a DELETE , INSERT or UPDATE statement affects the salary = ' || :NEW.salary || ',
tbl_employees table(Salary Column)- The trigger should be FOR ');
EACH ROW trigger. DBMS_OUTPUT.PUT_LINE
SAMPLE OUTPUT : Fahan,Karn: Old salary = 3500, New salary = ('Difference: ' || sal_diff);
4500, Difference: 1000 END;

Carefully read the question and answer accordingly.


Select the key advantages of using Store procedures in database Execution plan retention
management system. and reuse
CREATE OR REPLACE
PROCEDURE
get_studentname(p_student
id IN
TBL_students.studentid
%TYPE) AS v_firstname
VARCHAR2(10);
v_lastname
VARCHAR2(10); CURSOR
c_student_name IS
SELECT firstname,
lastname FROM
TBL_students WHERE
studentid = p_studentid;
BEGIN OPEN
Carefully read the question and answer accordingly. c_student_name; LOOP
In the Student Management system we have a table called FETCH c_student_name
STUDENTS with attributes STUDENID ,FIRSTNAME , LASTNAME. INTO
TABLE DATA: v_firstname,v_lastname;
STUDENTID FIRSTNAME LASTNAME EXIT WHEN
10001 Francis Peter c_student_name
10002 Venkat Prasad %NOTFOUND;
Which PLSQL block in the options concatenates both the Firstname DBMS_OUTPUT.PUT_LINE
and Lastname with ',' symbol. NOTE : STUDENTID should be passed (v_firstname','v_lastname);
as parameter. END LOOP; CLOSE
SAMPLE OUTOUT : Francis,Peter c_student_name; END;

Carefully read the question and answer accordingly.


Which of the following SQL statements will calculate and return the SELECT ABS(-80)
absolute value of -80? "Absolute" FROM DUAL

Carefully read the question and answer accordingly.


XYZ company database has Customer personal information View
table using which customer can update their personal information like
address, phone number fields when user updates address and phone
number fields in view table. We need to take care of updating address
and phone number fields in underlying database base table
automatically. What right solution do you suggest to implement this
requirement? Implement using Cursors
DECLARE c_id
customers.id%type; c_name
customers.name%type;
c_addr customers.address
%type; BEGIN CURSOR
c_customers is SELECT id,
name, address FROM
customers; OPEN
c_customers; LOOP FETCH
Carefully read the question and answer accordingly. c_customers into c_id,
We have customer table with the following values c_name, c_addr;
ID NAME AGE ADDRESS SALARY dbms_output.put_line(c_id ||
1 Ramesh 26 Delhi 25000 ' ' || c_name || ' ' || c_addr);
2 Khilan 22 Chennai 30000 EXIT WHEN c_customers
What will be the code to execute all the 3 records from the customer %notfound; END LOOP;
and to print the name and address in a single line. For example : CLOSE c_customers;
Ramesh Delhi END; /

Carefully read the question and answer accordingly.


Consider the following SQL statements:
CREATE Table dept (deptno number (2), deptname varchar (20), loc
varchar (20));
ROLLBACK The Describe statement
DESCRIBE dept displays the structure of the
Which of the following statement is true about the above? Department table.
DECLARE TYPE
TimeTyprec IS RECORD
( minutes DATE, hours
DATE ); TYPE
Meetingmode IS RECORD (
day DATE, time_of
TimeTyprec, dept
TBL_departments
%ROWTYPE, place
VARCHAR2(20), purpose
VARCHAR2(50) ); TYPE
ToMeet IS RECORD ( day
DATE, time_of DATE, dept
TBL_departments
%ROWTYPE, place
VARCHAR2(20), purpose
VARCHAR2(50) ); meeting
Meetingmode; seminar
ToMeet; BEGIN
Carefully read the question and answer accordingly. seminar.time_of :=
Which is the valid code to declare the nested records meeting.time_of; END;

Carefully read the question and answer accordingly.


XYZ company database has SALES table which captures all Use Aggregate function
department sales information. You have been asked to create along with GROUP BY
department wise summarized total sales report from SALES table. clause in query to retrieve
Which of the following correct option will fetch you meaning full result? result
DECLARE CURSOR c1 is
SELECT employeeid,
firstname||','||lastname
"Name" , salary FROM
tbl_employees ORDER BY
salary DESC; v_employeeid
NUMBER; v_name
VARCHAR2(30); v_salary
Carefully read the question and answer accordingly. NUMBER; BEGIN OPEN
Which anonymous block to select first 3 highest paid salary and to c1; FOR i IN 1..3 LOOP
insert into a temp table without any duplicate entry. FETCH c1 INTO
TABLE DATA : TBL_EMPLOYEES v_employeeid, v_name,
EmployeeID Salary DepartmentID v_salary; INSERT INTO
258963 3000 20 temp VALUES
257896 6000 30 (v_employeeid, v_name,
457892 3000 40 v_salary); EXIT WHEN
564232 3000 40 c1%NOTFOUND; COMMIT;
254589 8000 50 END LOOP; CLOSE c1;
784555 5000 20 END;

Carefully read the question and answer accordingly.


Consider you are maintaining XYZ company database. XYZ database
tables are accessed by several users to fetch daily reports by joining
multiple tables found each user writes query which is more than 100
line of SQL statement and submits to server for processing in order to
fetch results. This is really increasing the network traffic and also
response time. What will the right solution you will implement in such
scenarios in order to increase performance? Create View

Carefully read the question and answer accordingly.


The below trigger is a Statement Level Trigger? State True or False?
CREATE or REPLACE TRIGGER After_Update_product
AFTER
insert On product
FOR EACH ROW
BEGIN
INSERT INTO product_check Values('After update, Row
level',sysdate);
END; TRUE
Carefully read the question and answer accordingly.
Does the below code assign NULL to a nested table?
DECLARE
TYPE Clientele IS TABLE OF VARCHAR2(64);
group1 Clientele := Clientele('Customer 1','Customer 2');
group2 Clientele;
BEGIN
group1 := group2;
END; TRUE

Carefully read the question and answer accordingly.


Does the below code compares 2 collections?
DECLARE
TYPE Clientele IS TABLE OF VARCHAR2(64);
group1 Clientele := Clientele('Customer 1', 'Customer 2');
group2 Clientele := Clientele('Customer 1', 'Customer 3');
BEGIN
IF group1 = group2 THEN
...
END IF;
END; TRUE

Carefully read the question and answer accordingly.


The below code checks whether the colletion is NULL and prints
NULL, state TRUE or FALSE?
DECLARE
TYPE emp_rec is RECORD (
firstname TBL_employees.firstname%TYPE,
lastname TBL_employees.lastname%TYPE
);
TYPE professor IS TABLE OF emp_rec;
members professor;
BEGIN

IF members IS NULL THEN


DBMS_OUTPUT.PUT_LINE('NULL');
ELSE
DBMS_OUTPUT.PUT_LINE('Not NULL');
END IF;
END;
/ TRUE
DECLARE x VARCHAR2
Carefully read the question and answer accordingly. (5); BEGIN SELECT
How to reference the below Packaged variables outside of PLSQL? pkg_var.dummy_var INTO x
CREATE OR REPLACE PACKAGE pkg_var AS FROM DUAL;
dummy_var CONSTANT VARCHAR2 (5) := 'xyz'; DBMS_OUTPUT.put_line
END pkg_var; (x); END;

Carefully read the question and answer accordingly.


A Service locator is best implemented as a singleton TRUE

Carefully read the question and answer accordingly.


Which design pattern used in creating connections using Java
Database Connectivity (JDBC) API Proxy pattern

Carefully read the question and answer accordingly.


The template pattern avoids code duplication by defining common
algorithm in base class and let the subclasses to implement the
variations in the algorithm TRUE

Carefully read the question and answer accordingly.


A developer designs a web application that must support multiple user
interfaces such as
1. XML based web services for Business to Business clients
2. HTML for web based clients
3. WML for wireless clients
Which design pattern provides the solution for this requirement. DAO

Carefully read the question and answer accordingly.


In the below code, if we declare List interface instead of ArrayList, it
would be easier to change any List implementation to store customer
details in future. By defining ArrayList here the programmer tightly
couples the ArrayList in his application.
class CustomerList {
ArrayList customerList;
public CustomerList(ArrayList list){
customerList=list;
}
} TRUE
Carefully read the question and answer accordingly.
As a developer, you are defining the logging service in the application.
There should be only one instance of logging service should be
defined so that multiple sources in your application can register and
use it. The logging service should be accessible by all sources of
application and hence you need to provide global point of access to
the service. Identify the pattern used for this scenario. singleton

Carefully read the question and answer accordingly.


You are developing a web application and based on the client
requests, your application has to share huge data files with respective
clients. To save the network bandwidth, the files have to be
compressed before sending the response. The logic for compressing
the data files should not be redundant though compression has to
applied for all the responses. Which design pattern should be used in
this scenario to avoid the duplication of the compression code? Intercepting Filter

Carefully read the question and answer accordingly.


The Java Remote Method Invocation (RMI) system allows an object
running in one JVM(Client) to invoke methods on an object running in
another JVM(Server). The RMI Client creates the local representation
of the remote object running in the server. Which design pattern
implemented in this scenario. Proxy pattern

Carefully read the question and answer accordingly.


Which are the pattern types are used for building loosely coupled
systems Creational pattern

It reduces network traffic by


combining multiple calls into
one network call and fetch
Carefully read the question and answer accordingly. and return multiple values in
Select the benefit of using Transfer Object design pattern one trip

Carefully read the question and answer accordingly.


We are developing a system that performs approval of various
purchasing requests. The approval authority can be a purchase lead
or purchase manager or purchase head based on the cost of the
purchase. The system should be flexible to select the approver based
on the cost of the purchase. Which design pattern should be used to
handle this situation. Bridge pattern
Carefully read the question and answer accordingly.
Observe the below code snippet.
public interface iPersistence{
public Object save(Object o);
public Object findBy(Object key);
}
public class PersistenceImp implements iPersistence{
public Object save(Object o){
....
}
public Object findBy(Object key){
....
}
}
As per the requirement, the iPersistence interface might be added
with few more methods in future. This leads to the change of code in
PersistenceImp class as well to provide implementation for new
abstract methods introduced. Which pattern should be used in this
scenario so that any change in the interface will not result in a change
in PersistenceImp class. Bridge pattern

Cohesion is the OO
Carefully read the question and answer accordingly. Concept which hides the
Which are the statements are true implementation

Carefully read the question and answer accordingly.


Consider that we are connecting to different data sources from our
application. If we couple the persistence code along with business
logic, then the change of data source in the application will affect the
business logic. Which design pattern is recommended to handle this
scenario to ensure that the change in data source would not affect the
business logic. . DAO Pattern
Singleton pattern ensures
Carefully read the question and answer accordingly. that only one object for the
Select the options which are true for Singleton pattern class created

Carefully read the question and answer accordingly.


A good designed application should have " tight coupling and low
cohesion" TRUE
Choice2 Choice3 Choice4 Choice5 Grade1

1&3 2&3 2&4 1&4

Depends on whether the


Displays “false” session is newly created
always Throws exception or not
1&3 2&3 2&4 1&4

Compilation and
output of the
contents of
menu.jsp followed Compilation, but runtime
by "Output after error, the buffer has
menu.jsp" Compilation error been flushed
By setting the
session-timeout By setting the
parameter in the setMaxInactiveInterval()
web.xml file to 1 method period to 60 By using the destroy()
minute seconds method

HttpSession session
= HttpSession session =
request.getSession(t request.getSession("jses None of the listed
rue); sionid"); options
Gives None of the listed
10 minutes illegalStateException options

WebApp.xml deployment.xml web.xml

HttpSession session HttpServletRequest


= session =
request.getSession( request.getSession();
); String url String url String url
=session.getAttribut =(String)session.getSess =(String)session.getAttri
e("URL"); ion("URL"); bute("URL");

Statement A is true
and statement B is Statement A is false and Statement A is false and
false. statement B is true. statement B is false.

By overriding the init By overriding the destroy By overriding the doGet


method in the method in the servlet method in the servlet
servlet class. class. class.
<servlet> <servlet- <servlet> <servlet- <servlet> <servlet-
name>hello</servlet name>myworld.hello</se name>hello</servlet-
-name> <servlet- rvlet-name> <servlet- name> <servlet-
class>myworld.hello class>hello</servlet- class>myworld.hello</se
</servlet-class> class> </servlet> rvlet-class> </servlet>
</servlet> <servlet- <servlet-mapping> <servlet-mapping>
mapping> <servlet- <servlet- <servlet-
name>hello</servlet name>hello</servlet- name>hello</servlet-
-name> <url- name> <url- name> <url-
pattern>/hello</url- pattern>/hello</url- pattern>hello</url-
pattern> </servlet- pattern> </servlet- pattern> </servlet-
mapping> mapping> mapping>

<HTML> <BODY>
<FORM
ACTION=http://local <HTML> <BODY>
host:8080/servlet/m <FORM
yservlet ACTION=http://localhost
METHOD=GET> :8080/servlet
<INPUT <HTML> <BODY> METHOD=GET>
TYPE=SUBMIT <INPUT TYPE=SUBMIT <INPUT TYPE=SUBMIT
VALUE=SUBMIT> VALUE=SUBMIT> VALUE=SUBMIT>
</FORM> </BODY> </FORM> </BODY> </FORM> </BODY>
</HTML> </HTML> </HTML>

RequestDispatcher
dispatcher = RequestDispatcher
request.getRequest dispatcher =
Dispatcher("Servlet2 request.getRequestDispa
"); tcher("Servlet2");
dispatcher.dispatch( dispatcher.chain(req, request.sendRedirect("S
req, resp); resp); ervlet2");
By storing the
content files under By storing the content By storing the content
the META-INF files under the WEB-INF files under the INF
directory directory directory

ServletResponse PrintStream ServletConfig

header Application ID Session ID

A firewall server will


One of the key tasks Based on rules set, the add security tokens to
of firewall is routing firewall server will filter the requests before
between a cluster of A Proxy server can be a the incoming requests passing to destination
servers firewall server over internet server

FALSE

FALSE

Statement A is true
and statement B is Statement A is false and Statement A is false and
false. statement B is true. statement B is false.

GET POST REQUEST


Servlets are robust Servlets only contains Each request in servlet
and object oriented. business logic. runs in separate thread.

Cluster Application Servers Proxy Server

Statement A is true
and statement B is Statement A is false and Statement A is false and
false. statement B is true. statement B is false.

Layered architecture can


Testing the be used to increase or Development will be
communication decrease the level of slower, because more
across multiple abstraction between layers to code &
layers is complex layers integration cost is higher

ServletRequest HttpServlet It is not a sub-interface

FALSE

JTA JPA JMS

FALSE
These are
responsible for
managing the
lifecycle of servlets,
mapping a URL
(Universal Resource
Locator) to a
particular servlet,
and ensuring that
the URL requester These are also referred
has got the correct to as Web containers or
access rights Web engines. All of the listed options

to provide the
configuration details to provide listener
on how the web information to notify has to list down the
server should use certain classes when external API's which are
them to serve the some events (like used in the web
incoming requests session creation) happen application

3&4 2&3 1&4

1 10

FALSE

<action> <param-name> <param-value>

Will be bundled inside


the application, hence
no need to deploy
Web Server Proxy Server individually None of the above

FALSE
FALSE

PrintWriter ServletContext ServletConfig

Application client
Web container container Applet container

FALSE

2&3&4 1&2&4 3&2 3&4

FALSE

To access the
application, the device
Web applications allows like mobile phones,
Little or no the users to invoke from tablets, computers need
diskspace is any device like mobile to open the port for
required on the phones, tablets that has connectivity to web
client browsers server

Load Balancer Application Servers Web Server

FALSE

session.removeSession(
session.isNew(false) session.invalidate() )
Cookies Hidden Field All of the listed options

addCookie() addSession() getSession()

TRUE

doPost() getSession() getValue()


Session timeout Session timeout Session timeout
declarations made declarations made declarations made
in the DD(web.xml) programmatically can programmatically can
can specify time in specify time only in specify time either in
minutes. seconds. minutes or seconds.

FALSE

setMaxInactiveInterv
al() setMaxInactive_interval() setInactiveInterval()

HttpSessionAttributeList
HttpListener HttpSessionListener ener

jsessionid servletid containerid


1&3 2&3 3&5 1&5

1&3 2&3 2&4 1&4

HttpServletRespons
e ServletContext HttpServletRequest

public void
doGet(HttpServletR public void
equest req, doGet(HttpServletReque
HttpServletRespons st req,
e res) throws HttpServletResponse
ServletException, res) throws
IOException ServletException,
{ session = IOException { Session
req.getSession(); session =
session.getAttribute( req.getSession();
"BookID","Core session.setAttribute("Boo None of the listed
Java"); } kID","Core Java"); } options

request.createSessi request.getSessionObjec
on() t() request.makeSession()

2&3 1&2 3&4


ServletContextListe None of the listed
ner HttpSessionListener options

ServletRequestAttrib None of the listed


uteListener HttpRequestListener options

ServletRequestListe HttpSessionBindingListe
ner HttpSessionListener ner

None of the listed


<listener-class> <listener-attribute> options

initiateContext() contextInitialized() start()

2&3 1&2 1&4

$
${init['company- ${initParam[“company- {contextParam.company
name']} name”]} -name}

2&4 3&4 4&5 1&5

#{expr} ${"expr"} $[expr]


null 7 error

FALSE

Nothing will be None of the listed


displayed 1 options

2&3 2&4 3&4

initParam headerValues pageContext

None of the listed


${Values.address} ${request.address} options

request.getParameter("u None of the listed


${param.userid} serid"); options
b c a,b,c

1&2&3 2&3 1&2&4 2&3&4

1&3 2&3 2&4 1&4

Statement A is true
and statement B is Statement A is false and Statement A is false and
false. statement B is true. statement B is false.
<%taglib
prefix="pre"
uri="testuri" %>
<html> <head> <%@ taglib prefix="pre" <%@ taglib prefix="pre"
<title>Demo on uri="testuri" %> <html> uri="testuri" %> <html>
helloworldCustom <head> <title>Demo on <head> <title>Demo on
tag</title> </head> helloworldCustom helloworldCustom
<h1> tag</title> </head> <h1> tag</title> </head> <h1>
<pre:helloworld <pre:helloworld <helloworld
attrib="John"> </h1> attrb="John"/> </h1> "attrb"="John"/> </h1>
</html> </html> </html>

Statement A is true
and statement B is Statement A is false and Statement A is false and
false. statement B is true. statement B is false.

javax.servlet.jsp.tag javax.servlet.jsp.tag.ext javax.servlet.jsp.tagext

b,d a,b,c c,d,e


<a href='<c:link <a href='<c:url <a href='<c:link
url="cognizant.jsp"/> value="cognizant.jsp"/>'/ value="cognizant.jsp"/>'/
'/> > >

<c:out value=${var}> <c:out var="var"> <c:expr value=var>

There is no standard tag


<c:when> <c:if> for switch

check expr test

2&3&4 1&2&4 3&2&5 3&4&5

<font color='green'>
<ul> <c:forEach
flag="errmsg" <font color='green'> <ul> <font color='green'> <ul>
items="$ <c:forEach flag="errmsg" <c:forEach flag=errmsg
{errorMsgs}"> <li>$ items="${errorMsgs}"> items="${errorMsgs}">
{errmsg}</li> <li>$errmsg</li> <li>${errmsg}</li>
</c:forEach> </ul> </c:forEach> </ul> </c:forEach> </ul>
</font> </font> </font>

<jsp:useBean
id="myBeanAttribute <jsp:useBean <jsp:useBean
" id="myBeanAttribute" id="myBeanAttribute"
class=”com.cts.MyB type=”com.cts.MyBean" type=”com.cts.MyBean"
ean" /> scope=”request”/> />
It will iterate over the
current It will iterate over the
ServletRequest current ServletRequest
parameters getting parameters and would
each property to the not set any property to
value of the It will give a run-time the value of the
parameter error. matching parameter

A message box stating


for user's confirmation
The execution of the about termination or
current page is A run time error is continuation of the
terminated. displayed. application is displayed.

<jsp:import
page=”user-
pref.jsp”> <jsp:import file=”user- <jsp:include path=”user-
<jsp:param pref.jsp”> <jsp:param pref.jsp”> <jsp:param
name=”userPref” name=”userPref” name=”userPref”
value=”$ value=”$ value=”$
{user.preference}” /> {user.preference}” /> {user.preference}” />
</jsp:include> </jsp:import> </jsp:include>

<jsp:useBean
<jsp:useBean id="account"
id="account" type="com.cts.Accoun
<jsp:useBean type="com.cts.Account” t" scope="session">
id="account" scope="session"/> <jsp:getProperty
type=”com.cts.Account” / <jsp:getProperty name="account"
<%= > <%= name="account" property="accountNu
employee.getAccou employee.getAccountNu property="accountNumb mber" />
ntNumber();%> mber(); %> er" /> </jsp:useBean>
The code sets value The code sets the values The code does not
of all properties of of all properties of compile as there is no
employee bean to employee bean with property attribute of None of the given
"*". default values. setProperty tag. option

<jsp:useBean
identity="login"
scope="Session" <jsp:useBean id="login"
class="s.beans.Logi <jsp:useBean id="login" scope="Session"
nBean"> <%! scope="Session" class="s.beans.LoginBe
login.setValue(reque class="s.beans.LoginBea an">
st.getParameter("Lo n"> <login.setValue(request.
ginid")); login.setValue(request.g getParameter("Loginid"))
login.setAddress(req etParameter("Loginid")); ;/>
uest.getParameter(" login.setAddress(request. <login.setAddress(reque
address")); %> getParameter("address")) st.getParameter("addres
<jsp:useBean> ; </jsp:useBean> s"));/> </jsp:useBean>

2&3 1&2 3&4


<jsp:getProperty
<Jsp:getProperty <Jsp:getProperty name="employee"
name="employee" name="employee" property="employee.em
property="EmpID"/> property="empId"/> pId"/>

<jsp:include
page='WEB-
INF/jsp/header.jsp'> <jsp:insert file='WEB-
<jsp:param INF/jsp/header.jsp'>
name='pageTitle' <jsp:include file='WEB- <jsp:param
value='Welcome INF/jsp/header.jsp'> $ name='pageTitle
Page'/> {pageTitle='Welcome value=”Welcome
</jsp:include> Page'} </jsp:include> Page” /> </jsp:insert>

page and request page, request, response page, response, session


only and application and application
<% if
(request.retrievePar
ameter("marks"))>=
60) { %>
<jsp:moveforward <% if
page="Ex.jsp"> <% if (request.getParameter("
</jsp:forward> <% } (request.getParameter(" marks"))>=60) { %>
else { %> marks"))>=60) { %> <jsp:jspparam="Ex.jsp">
<jsp:moveforward <jsp:forward </jsp:forward> <% } else
page="Av.jsp"> page="Ex.jsp" /> <% } { %>
</jsp:forward> <% } else { %> <jsp:forward <jsp:jspparam="Av.jsp">
%> page="Av.jsp"> <% } %> </jsp:forward> <% } %>

<jsp:setProperty>
<jsp:useBean> and <jsp:getProperty> and <jsp:useBean> and
<jsp:include> <jsp:forward> <jsp:plugin>

Info autoflush extends

The value will be


always displayed as The syntax error would The value will be equal
1. be displayed. to 10.

application out page


Config Exception Request

request response PageContext

It will display the It will display time as It will display the current
date and time. hh/mm/ss. time as hh:mm:ss.

Declaring <scripting- Putting scripting-


invalid> tag at the invalid=true attribute in Scripting can’t be
top of JSP page form tag blocked

Directive Expression Declaration

in request response

Write a block of java


Declare a variable Import a java class code

FALSE

session extends language


<html> <% String
message="hello
world"; String <html> <%= String <html> <%! String
getMessage() message="hello world"; message="hello world";
{ return message; } String getMessage() String getMessage()
%> Message for { return message; } %> { return message; } %>
you:<%= Message for you:<%= Message for you:<%!
getmessage() %> getMessage() %> getMessage() %>
</html> </html> </html>

< %! String < %@ String < %= public String


name="Rocky"; % > name="Anand" % > name="Anand"; % >

isScriptingEnabled session language

<%@ include <% page


file="Header.html" <jsp:forward import="Header.html"
%> page="Header.html"> %>

<%@ page
ErrorPage="true" <%@ page <%@ page
%> isErrorPage="false" %> ErrorPage="false" %>

It is NOT possible to
String x = (String) access the pageContext String x = (String)
pageContext.getReq object from within pageContext.getReques
uestScope("foo"); doStartTag. t().getAttribute("foo");

<%@ include
<%@ page <%@ include autoFlush="java.util.*"
session="true*" %> import="java.util.*" %> %>
<% page import <% import="java.util.*" <% import java.util.*
java.util.* %> %> %>
The ServletConfig
object is contained
within the Defines an object to
ServletContext provide client request
object. information to a servlet All of the listed options

void
setAttribute(String void setAttribute(Object void setAttribute(Object
name, String value) object,String name) object, Object object)

javax.Servlet.Config javax.Config Servlet.Config

after constructor
runs after service() runs after servlet is loaded

<servlet> <servlet-mapping > <url-pattern>

None of the listed


String Attribute options

getServletName(String getInitParameterName(
getParameter() name) String name)
void void void
clearAttribute(String removeAttribute(Object removeAttribute(String
name) name) name)

public void
_jspService(HttpSer public void public void
vletRequest request, _jspService(HttpServletR _jspService(HttpServlet
HttpServletRespons equest request, Request request,
e response)throws HttpServletResponse HttpServletResponse
ServletException, response)throws response)throws
java.io.IOException ServletException java.io.IOException
JasperException CompilerException JSPCompilerException

The source Servlet


file HTML The compiled Servlet file

FALSE

It will compile
Line 5 is invalid Line 6 is invalid successfully and print 48

FALSE

MalformedElementExcep
JasperException tion TranslationException

None of the listed


_jspService() jspDestroy() options

Container doesn't mind


Compilation Translation JSP syntax errors

jspInitit() jspInit() jspInitialization()

FALSE
It depends on the servlet
WEB-INF/classes container settings WEB-INF/class

FALSE
None of the listed
Execution Undeployment options

FALSE

JSP page is
translated to a
servlet, code is JSP is compiled, JSP JSP is loaded into
compiled, servlet is page is translated to a memory, Code is
loaded into memory, servlet, code is loaded, compiled, instance is
instance is created instance is created created

FTP SMTP No need of any protocol

jspService() _jspService() jspInitialization()

FALSE

None of the listed


<scripting-invalid> <scripting-disabled> options

ServletHttpRequest ServletRequest HttpRequest

Multithreading
support JSP support Application Controller

Statement A is true
and statement B is Statement A is false and Statement A is false and
false. statement B is true. statement B is false.
<load-on-start> <loadonstartup> <load-on-Init>

2&3 1&2 3

jspDestory() jspDelete() jspStop()

View Controller Connector

None of the listed


Will display 18 Will display 15 options

FALSE

Servlets are written Servlets are written in the Servlets are written in
in the Java script C++ the PHP

jsp_Service() jspService() service()

FALSE

Web Application
ARchive Web Application Request Web Application Report
invoking, destroy.
Web Browser loading invoking, destroy.
manages this life User Should manages None of the listed
cycle this life cycle options

FALSE

FALSE

None of the listed


isELIgnored isErrorPage options

Scriptlet code gets no


The service method The doGet() method of place in the generated
of generated servlet generated servlet servlet

By creating security By modifying the web By implementing the


constraints deployment descriptor Listeners

chain.doFilter(reque request.forward(request, request.doFilter(request,


st, response); response); response);
1&3 2&3 2&5 1&5

doFilter destroy doGet

Xerces Xmlspy Tag Library Descriptor

empty scriptless tag dependant

By using taglib By using path to the tag


directive. By using unique variable. handler.

1&3 2&3 2

FALSE

TRUE
super class show sub class show method
method super class show method Compilation Error

TRUE

final,interface public,friend final,protected private,abstract

FALSE

Constructor is a special Constructors should be


Constructors can be type of method which called explicitly like
overridden. may have return type. methods

TRUE

Inheritance Implementation Access specifier Class


II & IV III I & III

protected or public None of the listed options private

display method
display method 10 display method display super class method
10 method 20 20 display method 10 10
super class exe
method super class None of the listed
display method Compilation error options

Public Constructor Destructor Variable

A class can be All members of abstract Protected is default


declared as class are by default access modifier of a
protected. protected child class

None of the listed


11 Compilation error options

FALSE
Composition Generic Polymorphic

1&3 2&3 3&4 2&4

FALSE
20 50 20 10 10 20

FALSE

Parent Child Parent Child


public void aM1(){} public
void aM2(){} public void
public void bM1(){} bM1(){} public void bM2() public void aM1(){}
public void bM2(){} {} public void bM2(){}

FALSE

Statement I is TRUE Statement I is FALSE & Statement I & II are


& II is FALSE II is TRUE FASLE
Statement I is TRUE Statement I is FALSE & Statement I & II are
& II is FALSE II is TRUE FASLE

FALSE

FALSE

1&2&3 2&3 1&2&4 2&4


Statement I is TRUE Statement I is FALSE & Statement I & II are
& II is FALSE II is TRUE FASLE

120, 60, 0 60,60,60 120, 120, 120


It will give None of the listed
ArithmeticException It will print 5 options

FALSE

FALSE
1&3 2&3 3&4 2&4

FALSE
public void aM1(){} public void bM2(){} All of the listed options

FALSE

FALSE
Compilation fails
because the private This class must also The code will compile as
attribute p.name implement the hashCode Object class's equals
cannot be accessed. method as well. method is overridden.

protected static abstract

No Output will be
Compilation Error Runtime Exception displayed
Compilation Error DigiCam do Charge Runtime Error

they're not equal t1's an No Output Will be


t1's an Object Object Displayed

FALSE
Runtime Error. WD 500 Compile Error.

FALSE

Statement I is TRUE Statement I is FALSE & Statement I & II are


& II is FALSE II is TRUE FASLE
Code will Compile Code will compile but
without any Error wont print any message Runtime Exception

FALSE

None of the listed


a compilation error options

Neither Statements A
Statement A alone Statement B alone nor B
dot scope resolution none of these

System.setGarbage
Collection(); System.out.gc(); System.gc();

34 4 Compilation error

new print main Object

implements throwed Integer Boolean

catch finally access exception

FALSE
13,12,0 13,13,0 12,13,-1

3 4 2

I->III->II->IV I->III->IV->II I->II->III->IV

FALSE

TRUE

Statement A is true
and Statement B is Statement A is false and Both Statements A and
false Statement B is true B are false
line 4 line 5 line 1

Option 3 Option 1 Option 4

Running Dead Blocked 0

Important job Important job running in


running in MyThread String in run MyThread String in run No Output

Support parallel Requires less overheads


operation of Increase system compared to
functions. efficiency. multitasking. None of the options.
The delay between
Exactly 10 seconds “Start!” being printed and If “Time’s Over!” is
after the “Start!” is “Time’s Over!” will be 10 printed, you can be sure
printed, “Time’s seconds plus or minus that at least 10 seconds
Over!” will be one tick of the system have elapsed since
printed. clock. “Start!” was printed.

Synchronized Synchronized abstract Synchronized


methods Synchronized classes classes interfaces

FALSE
Important job
running in MyThread Runtime Exception Non of the options

The code executes The code executes


normally and prints normally, but nothing is
"Run". printed. Compilation fails.

notify() notifyAll() all the options

void start() boolean getPriority() boolean isAlive()

FALSE
Statement2 is TRUE
but Statement1 is BOTH Statement1 & BOTH Statement1 &
FALSE. Statement2 are TRUE. Statement2 are FALSE.

1&3 2&3 1&4 2&4

The code executes and


An exception is The code executes and prints
thrown at runtime. prints "Runner". "RunnerRunnerRunner".

It will compile and Compilation will cause


calling start will print an error because while
out the increasing The code will cause an cannot take a parameter
value of i. error at compile time. of true.
Two Three Four

In Line 4 null pointer


exception will occur as
Line 2 has run time String string contains null Line 4 has neither error
exceptions value nor exceptions.

FALSE

FALSE

FALSE

FALSE

None of the listed


False options

FALSE
Statement A is true
and Statement B is Statement A is false and Both Statements A and
false Statement B is true B are false

list Iterator foreach Iterator

Creates a Date
object with '01-01- Creates a Date object Creates a Date object
1970 12:00:00 AM' with current date and with current date alone
as default value time as default value as default value

B C D E

void Object String

FALSE

1&3 2&3 1&4 2&4


Statement A is true
and Statement B is Statement A is false and Both the statements A
false Statement B is true and B are false.

FALSE

FALSE

TRUE

FALSE

java.util.ArrayList java.util.Dictionary java.util.HashMap

FALSE

FALSE

FALSE
FALSE

String Object set1

Set SortedList SortedQueue

compare compareTo compareWith

SortTable SortedSet Comparable


The elements in the
collection are The elements in the
guaranteed to be collection are accessed HashSet allows at most
unique using a unique key. one null element

TRUE

Prints the output [Green


Compilation error at Throws Runtime World, Green Peace] at
line no 8 Exception line no 9
[10] Compilation error [abc]

Array List Collection Sorted Map


The ListIterator The ListIterator interface The ListIterator interface
interface extends provides the ability to provides forward and
both the List and determine its position in backward iteration
Iterator interfaces the List. capabilities.

All implementations All implementations are all implementations are


support having null serializable and immutable and supports
elements. cloneable duplicates data

1&3 2&3 1&4 2&4

None of the listed


5 6 options

FALSE
both strings are not
equal compilation error Runtime error

FALSE

Strings cannot be
both strings are not compare using ==
equal compilation error operator

FALSE

x = Java x = Rules Error

FALSE

FALSE
x="" x = Java x="JAVA"

FALSE

Statement I is TRUE Statement I is FALSE & Statement I & II are


& II is FALSE II is TRUE FASLE

Searching strings Extracting strings All of above

Statement I is TRUE Statement I is FALSE & Statement I & II are


& II is FALSE II is TRUE FASLE

FALSE
Strings cannot be
both strings are not compare using ==
equal compilation error operator

false true true true false false

A A,C Runtime error


Compilation fails finally finally exception finished

catch ( Exception e ) throws Exception No code is necessary.

finally block will be


The use of always executed in any
System.exit() circumstances. The death of the thread
hello 0 Math hello Math problem occur
problem occur string problem occur hello string problem
stopped problem occurs stopped occur stopped

TRUE

1&3 2&3 1&4 2&4

Throwable RunTimeException FileNotFindException

RunTimeException are
Runtime exceptions the exceptions which
include arithmetic forces the programmer
exceptions, pointer RuntimeException is a to catch them explicitly
exceptions class of I/O exception in try-catch block
Executing try
Runtime Exception Compile Time Exception Runtime Exception

Compiler time error


User defined Compile time error Run time error test()
exceptions should Cannot use Throwable to method does not throw a
extend Exception catch the exception Throwable instance

Array Index Out Of Number Format


Bounds Exception ClassNotFoundException Exception

None of the listed


A Compilation error options
NoClassDefFoundEr
ror means that the
class was found by
the ClassLoader
however when trying
to load the class, it
ran into an error NoClassDefFoundError
reading the class is a subClass of
definition. ClassNotFoundException None of the options

1&2&3 1&3 2 2&3

after switching from try


if exception occurs, catch block is not block to catch block the
control switches to mandate always only control never come back
following first Catch finally followed by try can to try block to execute
block be executed rest of the code
1&2&3 1&3&4 1&2&4 2&4

Shows unhandled
exception type
IOException at line Demands a finally block Demands a finally block
number 5 at line number 4 at line number 5

FileNotFoundExcept
ion SQLException NullPointerException
3 compilation error

FALSE

FALSE

FALSE

Statement A is true
and Statement B is Statement A is false and Both Statements A and
false Statement B is true B are false

A catch block can Both catch block and


have another try finally block can throw
block nested inside exceptions All of the listed options

final thrown catch

FALSE
finally throw throwable

FALSE

Checked exceptions are


the object of the
error and checked Exception class or any of
exceptions are its subclasses except All runtime exceptions
same. Runtime Exception class. are checked exceptions

FALSE

throws throw RuntimeException

FALSE

1&5 2&3 1&4 2&4

FALSE
None of the listed
error compilation error options

None of the listed


compilation error Runtime error options

FALSE

FALSE

statement 1:false statement 1:false statement 1:true


statement2:true statement2:false statement2:false
setting up
BufferedOutputStrea
man , an application
can write bytes to
the underlying As bytes from the
output stream stream are read or
without necessarily skipped, the internal
causing a call to the buffer is refilled as
underlying system necessary from the
for each byte contained input stream,
written. it has flush() method many bytes at a time.

FALSE

None of the listed


Serializable Externalizable options

TRUE

FALSE

StringReader File String

ObjectInput ObjectFilter FileFilter

1&2&3 1&3&4 1&2&4 2&4

FALSE
FALSE

FALSE

FALSE

FALSE

/java/system system compilation error

Writer Reader OutputStream

Jump exit goto escape

10.9873.765 Compilation error 10.987

Both by value &


by reference reference none of these

continue break label branch

for while do …. While for..each


0,6 6,0 0,5

2 4 8 64

FALSE

The number 1 gets The number 2 gets The number 3 gets The program
printed with printed with printed with generates a
AssertionError AssertionError AssertionError compilation error.

False Compilation error Runtime Exception

10 Compilation error Runtime Exception


a,z 91,97 97,91

None of the listed


False compilation error options

compilation error Runtime Error compiles and prints 12

code will execute with out


Compilation error printing runtime Exception
Wrapper Primitive Wrapper Primitive None Of the options

None of the listed


11 12 options

break continue new none

FALSE

ODBC drivers Both A and B None of the above

ODBC written in ODBC written in C++ ODBC written in Basic


Java language language language
3&4 2&3 1&4 2&4

Type 2 driver Type 3 driver Type 4 driver


All kinds of Statements
(i.e. which implement a
ParameterizedState ParameterizedStatement sub interface of
ment and CallableStatement Statement)

setConnection() Connection() getConnetion()

The code will "SELECT * FROM


display all values in Class.forName must be Person" query must be
column named mentioned after passed as parameter to
column1 Connection statement con.createStatement()
FALSE
Call method
executeProcedure() Call method execute() on Call method run() on a
on a Statement a StoredProcedure ProcedureCommand
object object object

Statement A is True
and Statement B is Statement A is False and Both Statements A and
False. Statement B is True. B are False.

Connection
cn=DriverManager.g Connection Connection
etConnection("jdbc: cn=DriverManager.getCo cn=DriverManager.getC
odbc:Mydsn", nnection("jdbc:odbc onnection("jdbc:odbc:ds
"username", ","username", n" ,"username",
"password"); "password"); "password");

java.sql.Date java.sql.Time java.sql.Timestamp

executeQuery() execute() noexecute()

db.sql pkg.sql java.sql

insertString() setString() setToString()

To execute DDL DDL statements cannot


statements, you be executed by making Support for DDL
have to install use of JDBC, you should statements will be a
additional support use the native database feature of a future
files tools for this. release of JDBC
started paused stopped

FALSE

Parametrized TableStatement Condition

FALSE

Parametrized PreparedStatement Condition

executeQuery() execute() noexecute()

java.jdbc and
java.jdbc.sql java.sql and javax.sql java.rdb and javax.rdb

select ename ,sal select ename ,sal select ename ,sal


,deptno from emp a ,deptno from emp a ,deptno from emp a
where a.sal > (select where a.sal <= (select where a.sal in (select
avg(sal) from emp b avg(sal) from emp b avg(sal) from emp b
where a.deptno = where a.deptno = where a.deptno =
b.deptno) order by b.deptno) order by b.deptno) order by
deptno; deptno; deptno;

3&4 2&3 1&4 2&4


Sales Marketing
Sales Marketing Department Marketing Cannot predict the
Department Marketing Sales Sales output of the query

34435 3443500 3443500 344350

adds 10 minutes to
the current adds 10 days to the date functions cannot
Timestamp current Timestamp query contains error be converted into char

Domain Integrity Entity Integrity Table Integrity

The above query


2 contains an error 5 20

Prints 0 Prints -1 Prints 6 Prints 14

All supplier record whose All supplier record


All supplier record name starts with % will whose name starts with ! None of the listed
will be displayed be displayed will be displayed options
Statement A is true
and Statement B is Statement A is false and Both Statements A and
false Statement B is true B are false

Top 2 student
record with lowest If LINE 1 is removed
marks will be Query will generate an than the query will
displayed error execute

Flashback Query
needs to be enabled Flashback Query does
and disabled using not apply to code objects
the like Packages,
DBMS_FLASHBAC Procedures, Function or None of the listed
K package. Triggers options

Create sequence Create sequence MySeq Create sequence MySeq Create sequence
MySeq ( Start with 2 ( Start with 2 Increment Start with 2 Increment MySeq as Start with 2
Increment by 1 ) by 2 ) by 2 Increment by 2

FALSE

It would be created It would be created and


and would use an It would be created and remains in a disabled
automatically would use an state because no index
created unique automatically created is specified in the
index. nonunique index. command.
It would remain disabled It would remain disabled It would remain
It would be and has to be enabled and can be enabled only disabled and has to
automatically manually using the by dropping the foreign be enabled manually
enabled and ALTER TABLE key constraint and re- using the ALTER
immediate. command. creating it. Constraint command.

FALSE

Mount the database, Start an instance, Mount Start the database, Start
Start the instance, the database, Open the the instance, Mount the
Open the database database(smo) Database

SPFILE SYSDBA FILE PFile

ALL should be Separate GRANT


replaced with a list WITH GRANT OPTION statements are required
of specific should be added to the for ORDERS and
privileges. statement. SUPPLIERS tables.

Data Dictionary
Cache Shared Pool Library Cache
The table is large and
One or more columns are most queries are
A column contains frequently used together expected to retrieve less
large number of null in a where clause or a than 2 to 4 % of the All of the listed
values. join condition. rows. options
A synonym with the A synonym with the A synonym with the
name UserDetails is name User is created name User is created
created and any and only system can use and any user can Incorrect syntax to
user can access it it access it create a synonym

FALSE

FALSE

DROP
PURGE ALL_TABLE_RECYCLE DROP Cannot drop tables
RECYCLEBIN BIN DBA_RECYCLEBIN from Recycle Bin

UNDO_TABLESPA
CE UNDO_RETENTION DBA_UNDO_EXTENTS

FALSE

Statement A is true Statement B is true and Both statements A and


and B is False. A is False. B are False.

Difference,Projectio Selection, Intersection, Intersection, Projection,


n, Join Join Join
You can join "n"
tables(all having
To join two tables single column primary
through an equijoin, the keys)in a SQL
You can join a You specify an equijoin columns in the join statement by
maximum of two condition in the SELECT condition must be specifying a minimum
columns through an or FROM clauses of a primary key an foreign of "n-1" join
equijoin. SELECT statement. key columns. conditions.

Select count(*) from Select count(*) from Select count(*) from


emp where sal > Select count(*) from emp emp where sal exist emp where sal in
(select Avg(sal) from where sal > (select (select avg(sal) from (select avg(sal) from
emp); Average(sal) from emp); emp); emp);

select empName , select empName ,


empNo from emp select empName , select empName , empNo from emp
where empno exists empNo from emp where empNo from emp where where empno
( select deptNo from empno in ( select deptNo empno has Any ( select between ( select
dept) from dept) deptNo from dept) deptNo from dept)

FALSE

Statement A is false Both statements A and B Both statements A and


and B is true. are true. B are false.
You want all You want all matched
unmatched data You want all matched You want all unmatched and unmatched data
from one table. data from both tables. data from both tables. from only one table.

Natural Join Non Equi Join Invalid Syntax for Join Inner Join

Statement A is false Both statements A and B Both statements A and


and B is true. are true. B are false.

1&5 2&3 1&4 2&4


3&4 2&3 1&4 2&4

NULL applesauce None of the listed option


IN Parameter value The IN parameter is a
should be passed to The same parameter will variable whose value will
the procedure for serve as input and change in the invoked
processing. output. procedure.

When the EXIT


statement is
encountered, the
condition in the
WHEN clause is
evaluated. If the
condition is true, the
loop completes and
control passes to The EXIT-WHEN
the next statement statement replaces a
after the loop simple IF statement. None of the above

FALSE NULL

Column constraints,
such as the NOT
NULL and check Column constraints, such
constraint, or default as the NOT NULL and
values are not check constraint, or %TYPE is used when
inherited by items default values are declaring variables to
declared using inherited by items hold database table
%TYPE. declared using %TYPE. values

FALSE
if you change the
database definition of
last_name, perhaps to
make it a longer
character string, the
datatype of v_last_name
memory changes accordingly at
consumption is less run time. faster processing

FALSE

Employee name whose


employee no is 101172
All employee names is printed if serveroutput The code does not Compiles and runs
will be printed is on compile at all without any output

FALSE NULL BLANK SPACE

FALSE

NULL string character

FALSE
1&2&3 1&3&4 1&2&4 1&3&5

Leads to compilation
error Displays nothing Leads to Exception
DBMS_OUTPUT.PUT_L
DBMS_OUTPUT.PU DBMSOUTPUT.PUT_LI INE(' The employee
TLINE NE name is : X')

%TYPE variables do
not inherit check %TYPE variables do not %TYPE variables inherit
constraint, inherit default values default values

Compiles , executes and Compiles , executes and Compilation fails due


Compilation fails Prints 100 Prints 50 to error on line 1
FALSE

index table nested table

Return FALSE if a
Return FALSE if no successful fetch has Return the number of
rows was returned been executed. rows fetched

In a table, if no single
Primary Key column can be assigned
constraint has to be uniquely as primary key,
explicitly dropped A primary key can be then a combination of
before completely referenced in another two columns can act as
removing the table. table as a Foreign Key. a Primary Key.

Invalid Variable None of the listed


Host Variable declaration Global Variable options

Associative arrays Varrays None of the listed option

12345.567 1234.5567 1.2345567

Only Statement1 is Only Statement2 is Statement1 and


True. False. Statement2 are False.
Compilation fails Compiles executes
due to error on line Compiles executes and Compiles executes and and prints 11 12 13
2 prints 12 Less prints 12 More More

The selector is
followed by one or
more WHEN
clauses, which are
checked
sequentially. The
value of the selector
determines which
clause is executed.
If the value of the
selector equals the
value of a WHEN- The ELSE clause does
clause expression, not works similarly to the
that WHEN clause is ELSE clause in an IF CASE statements can
executed statement be labeled

.- ( hyphen) %(percent sign) * (asterisk)

FALSE
The Subprograms that
A package body are present inside a
appears without package cannot exists
package A package can be separately as database
specification invoked by itself. objects.
max_days_in_year CONSTANT
CONSTANT max_days_in_year
INTEGER := 366; INTEGER := 366; None of the listed option
Value before
change (:OLD) :
Value before delete Value before change
Value After change (:OLD) : Null Value After
(:NEW) : Null change (:NEW) : Not Null None of the above

A GOTO statement
can transfer control
from one IF
statement clause to
another, or from one
CASE statement A GOTO statement can A GOTO statement
WHEN clause to transfer control into an cannot transfer control
another. exception handler. out of a subprogram.

When an EXIT When an EXIT


statement is statement is
encountered, the When an EXIT statement encountered, the loop
loop completes is encountered, the loop does not gets completed
immediately and completes immediately immediately and control
control passes to and control passes to the passes to the end of the
the next statement end of the program program

VALUE_ERROR SELF_IS_NULL PROGRAM_ERROR

(ii) (i) & (ii) None of the listed option

exceptions procedures functions

FALSE
Conditional
expressions of the
WHERE and The VALUES clause of The SET clause of the
HAVING clauses the INSERT statement UPDATE statement
OUT IN OUT None of the listed option

Executable Exception All Listed options

CREATE OR
REPLACE
TRIGGER
check_sal BEFORE
UPDATE OF sal ON CREATE OR REPLACE CREATE OR REPLACE
emp FOR EACH TRIGGER check_sal TRIGGER check_sal
ROW WHEN BEFORE UPDATE OF AFTER UPDATE OR sal
(new.sal < old.sal sal ON emp WHEN ON emp WHEN
OR new.sal > old.sal (new.sal < old.sal OR (new.sal < old.sal OR
* 1.1) BEGIN new.sal > old.sal * 1.1) -new.sal > old.sal * 1.1)
RAISE_APPLICATI BEGIN BEGIN
ON_ERROR ( - RAISE_APPLICATION_ RAISE_APPLICATION_
20508, ‘Do not ERROR ( - 20508, ‘Do ERROR ( - 20508, ‘Do
decrease salary not not decrease salary not not decrease salary not
increase by more increase by more than increase by more than None of the listed
than 10%’); END; 10%’); END; 10%’); END; options

compile-time error no error None of the listed option

result in mutating table


throws EXCEPTION error None of the listed option
FALSE

combined(positional and
named named) None of the listed option

FALSE

Statement-level FOR EACH ROW trigger Statement-level trigger FOR EACH ROW
trigger on the EMP on the AUDIT_TABLE on the AUDIT_TABLE statement-level trigger
table. table. table. on the EMP table.

1&5 2&3 1&4 4&5

1&4 2&3 3&4 2&4


FALSE

dbms_output.put_line(se dbms_output.put_line(
dbms_output.put_lin dbms_output.put_line(se cond_rec.nested_rec.var second_rec.nested_re
e(second_rec.var1); cond_rec.first_rec.var1); 1); c.first_rec.var1);

None of the listed


Trigger body Trigger event Trigger timing options

precision of the datatype of the optional value for the


parameter parameter parameter

PL/SQL procedure PL/SQL procedure Can


cannot contain contain a RETURN RETURN statement Not
RETURN statement statement with a single allowed in PL/SQL
without a value value procedure

When a PL/SQL-
packaged construct The package
is referenced for the specification may also
first time, the whole include PRAGMAs, PRAGMAs are not
package is loaded which are directives to allowed as part of
into memory the compiler package specification

combined(positional and
named named) None of the listed option
None of these
commands; you cannot
ALTER employees ALTER TABLE disable multiple triggers
DISABLE ALL employees DISABLE on a table in one
TRIGGERS; ALL TRIGGERS; command.

USER_SOURCE USER_OBJECTS USER_SOURCES


Sheela, Syed, Syed, Sheela,Raji, Raji, Syed, Sheela, No output is
Veena, Raji Veena Veena displayed.

FALSE

Functions called
from: An UPDATE Functions called from:
or DELETE An UPDATE or DELETE
statement on a table Functions called from: • statement on a table T
T cannot query or A SELECT statement can query or contain
contain DML on the can contain DML DML on the same table
same table T statements T

FALSE

The trigger fails The trigger fails because


because it needs to The trigger fails because you cannot use the
be a row level a SELECT statement on minimum and maximum
AFTER UPDATE the table being updated functions in a BEFORE
trigger. is not allowed. UPDATE trigger.

OUT IN None of the listed option


Using the %TYPE Using the %ROWTYPE the parameter size
definition definition specification

ex_invalid_id
exception will be The program will be TOO MANY ROWS
raised terminated abruptly. exception will be raised

Replacing Replacing
RAISE_APPLICATI Replacing RAISE_APPLICATIO
ON_ERROR(- RAISE_APPLICATION_ N_ERROR(-20000,
20000, 'no negative ERROR(-20000, 'no 'no negative age
age allowed'); to negative age allowed'); allowed'); to
RAISE_APPLICATI to RAISE_APPLICATIO
ONS_ERROR(- RAISE_APPLICATIONS N_ERROR(-
20000, 'no negative _ERROR(-20000,”no 20000,”no negative
age allowed'); will negative age allowed”); age allowed”); will
give the desired No problem in the trigger. will give the desired give the desired
output It gives the desired result output output
FALSE

Declare , Open , Declare , Fetch , Open Define , Open ,


Fetch , Close Open , Fetch , Close Fetch Fetch , Close

The value of a
cursor variable can Two types of cursors are
be stored in a 1) Strongly typed and 2) Null cannot be assigned
database column Weakly Typed. to a cursor variable

The select
statement provided
within the cursor
statement gets Open statement retrieves
executed when we the rows from the cursor The active set pointer is
open the cursor. and will process it. set to the second row.

The lock will not be


The records will be released even if we issue
available for our ROLLBACK or
changes only. COMMIT . None of the above

Replace the code as


declare EnameUser
Replace the above Emp.ename%type;
code as declare MrgUser Emp.Mrg
enameUser %type; cursor c1 is
varchar(20); select
MrgUser Replace the above code EnameUser,MrgUser
varchar(20); begin as declare enameUser from Emp; begin open
select ename,Mrg Emp.ename%type; c1; loop fetch c1 into
into MrgUser Emp.Mrg%type; EnameUser,MrgUser;
enameUser,MrgUse begin select ename,Mrg exit when
r from Emp; into enameUser,MrgUser c1%NOTFOUND;
dbms_output.put_lin from Emp; dbms_output.put_line('
e('Employee '|| dbms_output.put_line('E Employee '||
enameUser||' Works mployee '||enameUser||' EnameUser||' Works for
for '||MrgUser); Works for '||MrgUser); '||MrgUser); end loop;
end; / end; / close c1; end;
create or replace
procedure
prcEmp_details(Em create or replace create or replace
pName varchar2) as procedure procedure
begin declare cursor prcEmp_details(EmpNa prcEmp_details(EmpNa
c1 is select * from me varchar2 OUT) as me varchar2 OUT) as
Emp where begin declare cursor c1 begin declare cursor c1
Ename=EmpName; is select * from Emp is select * from Emp
begin for rec in c1 where where
LOOP Ename=EmpName; Ename=EmpName;
dbms_output.put_lin begin for rec in c1 LOOP begin for rec in c1 LOOP
e(c1.ename||’ ’|| dbms_output.put_line(rec dbms_output.put_line(c1 None of the listed
c1.empNO||’ ’|| .ename||’ ’||rec.empNO||’ .ename||’ ’||c1.empNO||’ options as procedures
c1.Mrg); end loop; ’||rec.Mrg); end loop; ’||c1.Mrg); end loop; cannot be created for
end; end; end; end; end; end; select statement

DECLARE
CURSOR DECLARE CURSOR
occupancy_cur IS DECLARE CURSOR occupancy_cur IS
SELECT pet_id, occupancy_cur IS SELECT pet_id,
room_number SELECT pet_id, room_number FROM
FROM occupancy room_number FROM occupancy WHERE
WHERE occupancy WHERE occupied_dt =
occupied_dt = occupied_dt = SYSDATE; BEGIN
SYSDATE; BEGIN SYSDATE; BEGIN FOR OPEN occupancy_cur
FOR occupancy_rec occupancy_rec IN FOR occupancy_rec IN
IN occupancy_cur occupancy_cur LOOP occupancy_cur LOOP
LOOP update_bill update_bill update_bill
(occupancy_rec.pet (occupancy_rec.pet_id, (occupancy_rec.pet_id,
_id, occupancy_rec.room_nu occupancy_rec.room_nu
occupancy_rec.roo mber); END LOOP; mber); END LOOP;
m_number); END CLOSE occupancy_cur; CLOSE occupancy_cur;
LOOP; END; END; END;

DECLARE
exception_name DECLARE
EXCEPTION exception_name DECLARE
PRAGMA EXCEPTION PRAGMA exception_name
EXCEPTION_INIT EXCEPTION_INIT EXCEPTION PRAGMA
(exception_name , (exception_name , EXCEPTION_INIT
err_code); Begin err_code); Begin (exception_name);
Execution section Execution section Begin Execution section
Exception WHEN Exception WHEN Exception WHEN
exception_name PRAGMA exception_init exception_name THEN
THEN Handle the THEN Handle the Handle the exception
exception END; exception END; END;
Whenever a DML
statement (INSERT,
For INSERT UPDATE and DELETE)
operations, the is issued, an implicit
implicit cursor holds cursor is not The implicit cursor is
the data that need automatically associated declared in the
to be inserted with this statement declaration section.

Compiles successfully
and terminates the
program due to an
Result is 10 Result is 0 Compilation fails Exception

FALSE

An software application Every time a software


links up with a Active application connect up
data objects, there is a with a database, there is
not much performance a performance value to
value to be paid. Not only be paid. Not only that,
You can think of a that, programs that programs that
record as a variable continually switch off continually switch off
that can hold a table between code and SQL between code and SQL
row or some colums can become quite can become quite
from a table row. complex. complex.
1&2&3 1&3&4 1&2&4 1&3&5

Statement A Is false Statement A is True and Both statements A and


and B is True. B is False. B are True.

When Only few


columns of one or
more tables needs When Programmer
to be referenced, needs to define a
stored and Failing to do this will customized structure for
processed. result in an error . accessing /storing data.

Compiles , executes Compiles , executes Compiles , executes Compiles , executes


prints 3 Delhi prints 3 Delhi 2 prints 3 Delhi Mumbai prints 3 Delhi Delhi
1&2&3 1&3&4 1&2&4 1&3&5

Compilation fails Compiles , executes


due to error on line Compilation fails due to Compilation fails due to and prints 1 2 3 4 5 6
2 error on line 3 error on line 4 7

Compilation fails Compiles , executes


due to an error on Compiles , executes and Compiles , executes and and prints 2, ,3 ,4, 5,
line 2 prints 1 , 2, ,3 ,4, 5, 6, 7 prints 1 , 2, ,3 ,4, 5, 6 6, 7
Cursor Record Custom Record Simple Record

Nested Table Associative Array None of the above

If v2:=ABC(); is removed
Compiles , executes than the code will Compiles fine and prints Compiles fine and
without any output compile and print 78 the output as 78 prints the output as 1

Compiles and prints Compiles and runs


8 Compiles and prints 10 Compiles and prints 1 without any output

Statement A Is false Statement A is True and Both statements A and


and B is True. B is False. B are True.
Both A and B are Statement A Is false and Statement A is True and
True B is True B is False

Associative Array Varray None of the above

1. Add a new genre. 1. Add a new genre. 2. Is 1. Add a new genre. 2.


2. Display the total # this genre id already in Display the total # of
of elements. 3. the collection? 3. **Add** elements. 3. **Add**
**Add** another another element to the another element to the
element to the varray. 4. Display the varray. 4. Is this genre id
varray. total # of elements. already in the collection?

TRUE

<br> <input> <h1>

Alternative text to be
ID used to identify displayed if the image is None of the listed
the image not displayed options

Provides additional None of the listed


behaviour to the tag Attribute is a type of tag options

None of the listed


frameset frames options

By using
rows=50%,50% By using colspan By using rowspan
3&4 2&3 1&4

minutes nanoseconds milliseconds

name value http-equiv

FALSE

1&2&3 1&3&4 1&2&4 1&3

None of the listed


II Both I & II options

None of the listed


II Both I & II options

TextArea Text All of the listed options


None of the listed
II Both I & II options

None of the listed


II Both I & II options

None of the listed


II Both I & II options

FALSE

1&2&3 1&3&4 1&2&4 1&3

3&4 2&3 1&4

TRUE

3&4 2&3 1&4

JavaScript can be Java Script can be


written inside the written as an external file
header and imported to the page All of the listed options
document.getEleme document.getElementsB None of the listed
ntsByTagName("p") yTagName("p[0]") options

document.getEleme document.getElementsB
ntsByTagName("p") yTagName("p[0]").innerte None of the listed
[0].innerText; xt() options

getElementsByTagName None of the listed


getElementById() () options

It will not print the It will display some error None of the listed
message message on browser options

<?xml None of the listed


version="1.0"?> <?xml version="1.0" /> options
<! ELEMENT
element-
name(element- <! ELEMENT element- None of the listed
content+)!> name(element-content)!> options

<message> if price <message> if price &lt; None of the listed


lt 60 </message> 60</message> options

Document Type None of the listed


Definition Dynamic Type Definition options
An Application can use
DTD are used as the DTD to validate the
contract between XML structure it has
two systems to received from external
interoperate. systems All of the listed options
None of the listed
II Both I & II options

eXtensible Markup Example Markup


Language Language X-Markup Language

None of the listed


DOM XHTML options

2 2&3 1

None of the listed


SAX XML options

None of the listed


XMLDOM XML options

None of the listed


SAX XML options

DocumentBuilder
DocumentBuilder b=factory.new None of the listed
b=new Builder(); DocumentBuilder(); options

Extensible Style Extensible Style Sheet None of the listed


Language Language options
DocumentBuilderFa
ctory f= DocumentBuilderFactory
BuilderFactory.newI f=DocumentBuilderFacto None of the listed
nstance(); ry.newInstance(); options

None of the listed


XSLT XSL-FO options

None of the listed


XSLT XSL options
3 1&3 1

Java API eXtensible Java API for XML None of the listed
Processing Processing options

None of the listed


javax.xml.*; javax.parsers.xml.*; options

<xs:complexType
name="CountrInfo"> <xs:complexType
<xs:choice> name="CountrInfo"><xs:
<xs:element sequence> <xs:element
name="countryNam name="countryName"
e" type="xs:string"/> type="xs:string"/>
<xs:element <xs:element
name="states" name="states"
type="xs:integer"/>< type="xs:integer"/></xs:s
/xs:choice></xs:com equence></xs:complexT None of the listed
plexType> ype> options

<xs:element <xs:element
name="CountryNam name="CountryName"
e" type="xs:string" type="xs:string" None of the listed
fixed="India"/> fixedvalue="India"/> options

<xs:complexType
name="CountrInfo"> <xs:complexType
<xs:choice> name="CountrInfo"><xs:
<xs:element sequence> <xs:element
name="countryNam name="countryName"
e" type="xs:string"/> type="xs:string"/>
<xs:element <xs:element
name="states" name="states"
type="xs:integer"/>< type="xs:integer"/></xs:s
/xs:choice></xs:com equence></xs:complexT None of the listed
plexType> ype> options

FALSE
2&3 1&3 3

createOutputFile()
testSomethingWithF testSomethingWithFile() deleteOutputFile()
ile() createOutputFile() createOutputFile()
deleteOutputFile() deleteOutputFile() testSomethingWithFile()

3&4 2&3 1&4

FALSE

1&2&3 1&3&4 1&2&4 1&3


Violation of best Possible performance
practice bottlenecks All of the listed options

PMD Checkstyle CPD

1&2&3 1&3&4 1&2&4 1&3

Improves Easy Improves Easy


understanding Maintenance All of the listed options

Refactor > Extract


Refactor > move method Refactor > move Method

3&4 2&3 1&4

3&4 2&3 2&4

2&3 1&3 3
1&2&3 1&3&4 1&2&4 1&3

SVN SCM HCM

finalize method static block code private method


By multitasking
CPU’s idle time is
minimized, and we A thread can exist only
can take maximum Two thread in Java can in two states, running
use of it. have same priority and blocked.

Serialization Synchronization Deserialization

TRUE

InputStream and
OutputStream None of the listed
Stream APIs Collection APIs options
None of the listed
PreparedStatement CallableStatement options

If the equals()
method returns
false, the If the hashCode() If the hashCode()
hashCode() comparison == returns comparison == returns
comparison == true, the equals() method true, the equals()
might return true must return true method might return true

When designing your


own collections class
(say, a linked list),
generics and
Generics and parameterized types
parameterized types allow you to achieve type
eliminate the need safety with just a single
for down casts when class definition as
using Java opposed to defining
Collections. multiple classes. All of the mentioned

java.util.LinkedHash
Set java.util.List java.util.ArrayList

Using object Using object None of the listed


serialization deserialization options
None of the listed
PreparedStatement CallableStatement options

java.util.Set java.util.List java.util.Collection

Implement using Implement using file None of the listed


Collection API’s. API’s options

ResultSetMetaData DataSource Statement

Mark Employee
class with final Make Employee class Make Employee class
keyword methods private methods public
Declare the Declare the
ProgrammerAnalyst ProgrammerAnalyst None of the listed
class has private class has final options

Both of them will be


executed None of them will be It is dependent on the
simultaneously executed operating system.

FALSE

java.lang.Double java.lang.StringBuffer java.lang.Character

FALSE
Allows
interoperability
among unrelated Reduces effort to learn All of the listed
APIs and to use new APIs Fosters software reuse options

HashMap LinkedHashMap Non of the listed options


Check whether you
have implemented Check whether you have
Customer class with marked Customer class
Externalizable methods with None of the listed
interface synchronized keyword options

FALSE
DECLARE TYPE
EmpRec IS DECLARE TYPE
RECORD ( emp_id EmpRec IS RECORD
emp.empno%TYPE, ( emp_id emp.empno
job_title %TYPE, job_title
VARCHAR2(9), VARCHAR2(9), salary
salary NUMBER(7,2));
NUMBER(7,2)); emp_info EmpRec;
emp_info EmpRec; emp_null EmpRec;
BEGIN BEGIN
emp_info.emp_id := emp_info.emp_id :=
7788; 7788;
emp_info.job_title := emp_info.job_title :=
'ANALYST'; 'ANALYST';
emp_info.salary := emp_info.salary := 3500;
3500; emp_info := emp_info := emp_null;
emp_null; END; END; None of the above

FALSE

CREATE TRIGGER
log_errors AFTER
SERVERERROR
ON DATABASE
BEGIN IF CREATE TRIGGER
(IS_SERVERERRO AFTER SERVERERROR
R (1017)) THEN ON DATABASE BEGIN
<special processing IF (IS_SERVERERROR
of logon error> (1017)) THEN <special
ELSE <log error processing of logon
number> END IF; error> ELSE <log error
END; number> END IF; END; None of the above

Use Cursors Use database Indexes Use database Trigger


Create Stored
Procedure Create index Create Trigger

CREATE OR
REPLACE
PACKAGE
employee_package
AS TYPE
t_ref_cursor IS REF
CURSOR; TYPE
emp_rec IS CREATE OR REPLACE
RECORD PACKAGE
( employeeid employee_package AS
NUMBER, firstname TYPE t_ref_cursor IS
VARCHAR2(10), REF CURSOR; TYPE
lastname emp_rec IS RECORD
VARCHAR2(10), ( employeeid NUMBER,
salary NUMBER); firstname VARCHAR2,
minimum_count lastname VARCHAR2,
CONSTANT salary NUMBER);
NUMBER := 4; minimum_count
FUNCTION CONSTANT NUMBER :=
get_employee 4; FUNCTION
RETURN emp_rec; get_employee RETURN
PROCEDURE emp_rec; PROCEDURE
update_salary update_salary
(employeeid IN (employeeid IN
NUMBER); END NUMBER); END None of the listed
employee_package; employee_package; options

Global enforcement
of business rules. Easier maintenance. If a
Define a trigger business policy changes, Improve performance in
once and then reuse you need to change only client/server
it for any application the corresponding trigger environment. All rules
that uses the program instead of each run in the server before All of the listed
database. application program. the result returns. options
COLLECTION_IS_N
ULL NO_DATA_FOUND VALUE_ERROR

FALSE

"Expressions have to be None of the listed


"String is not active" of SQL types" options

SELECT dept_id,
MIN (salary), MAX SELECT dept_id, MIN
(salary) FROM SELECT dept_id, (salary), MAX (salary)
employees WHERE MIN(salary), MAX(salary) FROM employees
MIN (salary) < 2000 FROM employees GROUP BY dept_id
AND MAX (salary) > HAVING MIN (salary) < HAVING MIN(salary) <
5000 GROUP BY 2000 AND MAX (salary) 2000 AND MAX (salary)
dept_id > 5000 > 5000
FALSE

None of the listed


Stored Procedure Functions Cursors options

"Value not "Reference to None of the listed


initialized" uninitialized collection" options
PROCEDURE
get_Coursename(p_
studentid IN
TBL_students.stude
ntid%TYPE) AS
v_studentid
NUMBER;
v_coursename
VARCHAR2(10); CREATE OR REPLACE
CURSOR PROCEDURE
c_course_name IS get_Coursename(p_stud
SELECT entid IN
co.coursename TBL_students.studentid
FROM %TYPE) AS
TBL_students s, v_coursename
courses co , VARCHAR2(10);
enrollments e CURSOR
WHERE s.studentid c_course_name IS
= p_studentid AND SELECT co.coursename
s.studentid = FROM TBL_students s,
e.studentid AND courses co , enrollments
e.courseid = e WHERE s.studentid =
co.courseid; BEGIN p_studentid AND
FOR s.studentid = e.studentid
v_rec_coursename AND e.courseid =
IN c_course_name co.courseid; BEGIN FOR
LOOP v_rec_coursename IN
DBMS_OUTPUT.PU c_course_name LOOP
T_LINE('Student v_studentid :=
With ID:'||' '|| p_studentid;
v_studentid||' DBMS_OUTPUT.PUT_LI
'||'Major Subject is'||' NE('Student With ID:'||' '||
'|| v_studentid||' '||'Major
v_rec_coursename. Subject is'||' '||
coursename); END v_rec_coursename.cours
LOOP; END ename); END LOOP; None of the listed
get_Coursename; END get_Coursename; options

Use Cursors Use database functions Use database Trigger

CREATE TABLE CREATE TABLE EMP


EMP (empno (empno NUMBER(4), CREATE TABLE EMP
NUMBER (4), ename VARCHAR2(35), (empno NUMBER(4),
ename VARCHAR2 deptno NUMBER(7,2) ename VARCHAR2(35),
(35), deptno NOT NULL, deptno NUMBER(7,2)
NUMBER (7,2) CONSTRAINT FOREIGN KEY
CONSTRAINT emp_deptno_fk CONSTRAINT emp
emp_deptno_fk FOREIGN KEY(deptno) deptno fk
REFERENCES dept REFERENCES REFERENCES
(deptno)) dept(deptno)) dept(deptno))
CREATE OR
REPLACE
PROCEDURE
Available_major(p_c
ourse
courses.coursenam
e%TYPE) IS CREATE OR REPLACE
v_courseid PROCEDURE
NUMBER; Available_major(p_cours
v_coursename e courses.coursename
VARCHAR2(20); %TYPE) IS v_courseid
v_deptid NUMBER; NUMBER;
BEGIN SELECT v_coursename
courseid VARCHAR2(20);
,departmentid, v_deptid NUMBER;
coursename INTO BEGIN SELECT courseid
v_courseid,v_deptid, ,departmentid,
v_coursename coursename INTO
FROM courses v_courseid,v_deptid,v_co
WHERE ursename FROM
coursename like courses WHERE
'p_course%'; coursename like
DBMS_OUTPUT.PU p_course||'%';
T_LINE('Course DBMS_OUTPUT.PUT_LI
Available with NE('Course Available
department ID:'||' '|| with department ID:'||' '||
v_deptid); v_deptid); EXCEPTION
EXCEPTION WHEN WHEN
NO_DATA_FOUND TOO_MANY_ROWS
THEN THEN
DBMS_OUTPUT.PU DBMS_OUTPUT.PUT_LI
T_LINE('No Course NE('No Course
Available'); END Available'); END None of the listed
Available_major; Available_major; options
CREATE OR
REPLACE
PROCEDURE
proc_get_details(p_
grade IN CREATE OR REPLACE
TBL_GRADE.grade PROCEDURE
%TYPE) AS proc_get_details(p_grad
v_studentid e IN TBL_GRADE.grade
NUMBER; %TYPE) AS v_studentid
v_coursename NUMBER;
VARCHAR2(10); v_coursename
v_grade NUMBER; VARCHAR2(10);
CURSOR c_grade v_grade NUMBER;
IS SELECT CURSOR c_grade IS
g.studentid, SELECT g.studentid,
co.coursename co.coursename FROM
FROM TBL_GRADE TBL_GRADE g,
g, COURSES co COURSES co WHERE
WHERE g.courseid g.courseid = co.courseid
= co.courseid AND AND g.grade = p_grade;
g.grade = p_grade; BEGIN OPEN c_grade;
BEGIN OPEN LOOP FETCH c_grade
c_grade; LOOP INTO v_studentid ,
FETCH c_grade v_coursename; EXIT
INTO v_studentid , WHEN c_grade
v_coursename; %NOTFOUND;
EXIT WHEN v_grade := p_grade;
c_grade DBMS_OUTPUT.PUT_LI
%NOTFOUND; NE('Student ID:'||' '||
v_grade := p_grade; v_studentid||' '||'grade
END LOOP; CLOSE is'||' '||v_grade); END
c_grade; END LOOP; CLOSE c_grade; None of the listed
proc_get_details; END proc_get_details; options

IF
old_company_rec.name
=
new_company_rec.name
AND
old_company_rec.incorp
_date =
new_company_rec.incor
p_date AND
old_company_rec.addres
IF old_company_rec s1 =
> new_company_rec.addre
new_company_rec) ss1 AND THEN ... the Records cannot be
THEN -------- END two records are compared with each
IF; identical ... END IF; other.
SUBSCRIPT_BEYOND_ None of the listed
NO_DATA_FOUND COUNT options

CREATE OR
REPLACE
TRIGGER CREATE OR REPLACE
salary_changes TRIGGER
BEFORE DELETE salary_changes
OR INSERT OR BEFORE DELETE OR
UPDATE ON INSERT OR UPDATE
TBL_EMPLOYEES ON TBL_EMPLOYEES
FOR EACH ROW DECLARE sal_diff
DECLARE sal_diff NUMBER; BEGIN
NUMBER; BEGIN sal_diff := :NEW.salary
DBMS_OUTPUT.PU - :OLD.salary;
T(:OLD.firstname||','| DBMS_OUTPUT.PUT(:O
|:OLD.lastname|| ': LD.firstname||','||:OLD.las
'); tname|| ': ');
DBMS_OUTPUT.PU DBMS_OUTPUT.PUT('Ol
T('Old salary = ' || d salary = ' || :OLD.salary
:OLD.salary || ', '); || ', ');
DBMS_OUTPUT.PU DBMS_OUTPUT.PUT('N
T('New salary = ' ew salary = ' ||
|| :NEW.salary || ', '); :NEW.salary || ', ');
DBMS_OUTPUT.PU DBMS_OUTPUT.PUT_LI
T_LINE('Difference: NE('Difference: ' ||
' || sal_diff); END; sal_diff); END;

Application Network bandwidth All of the listed


modularization conservation Improved security options
CREATE OR
REPLACE
PROCEDURE
get_studentname(p_
studentid IN
TBL_students.stude
ntid%TYPE) AS
v_firstname CREATE OR REPLACE
VARCHAR2(10); PROCEDURE
v_lastname get_studentname(p_stud
VARCHAR2(10); entid IN
CURSOR TBL_students.studentid
c_student_name IS %TYPE) AS v_firstname
SELECT firstname, VARCHAR2(10);
lastname FROM v_lastname
TBL_students VARCHAR2(10);
WHERE studentid = CURSOR
p_studentid; BEGIN c_student_name IS
OPEN SELECT firstname,
c_student_name; lastname FROM
LOOP FETCH TBL_students WHERE
c_student_name studentid = p_studentid;
INTO BEGIN OPEN
v_firstname,v_lastna c_student_name; LOOP
me; EXIT WHEN FETCH c_student_name
c_student_name INTO v_firstname; EXIT
%NOTFOUND; WHEN c_student_name
DBMS_OUTPUT.PU %NOTFOUND;
T_LINE(v_firstname| DBMS_OUTPUT.PUT_LI
|','||v_lastname); NE(v_firstname||','||
END LOOP; CLOSE v_lastname); END
c_student_name; LOOP; CLOSE None of the listed
END; c_student_name; END; options

SELECT ABS(-80),
Absolute FROM SELECT ABS("-80") SELECT ABS('-80')
DUAL Absolute FROM DUAL Absolute FROM DUAL

Implement using Implement using


Stored Procedures functions Implement using triggers
DECLARE c_id
customers.id%type;
c_name
customers.name
%type; c_addr DECLARE c_id
customers.address DECLARE c_id customers.id%type;
%type; CURSOR customers.id%type; c_name
c_customers is c_name customers.name customers.name%type;
SELECT id, name, %type; c_addr c_addr
address FROM customers.address customers.address
customers; BEGIN %type; CURSOR %type; CURSOR
OPEN c_customers; c_customers is SELECT c_customers is SELECT
LOOP FETCH id, name, address FROM id, name, address
c_customers into customers; BEGIN FROM customers;
c_id, c_name, OPEN c_customers; BEGIN LOOP FETCH
c_addr; LOOP FETCH c_customers into c_id,
dbms_output.put_lin c_customers into c_id, c_name, c_addr;
e(c_id || ' ' || c_name c_name, c_addr; dbms_output.put_line(c_
|| ' ' || c_addr); EXIT dbms_output.put_line(c_i id || ' ' || c_name || ' ' ||
WHEN c_customers d || ' ' || c_name || ' ' || c_addr); EXIT WHEN
%notfound; END c_addr); END LOOP; c_customers%notfound;
LOOP; CLOSE CLOSE c_customers; END LOOP; CLOSE
c_customers; END; / END; / c_customers; END; /

The DESCRIBE Dept


statement displays the
The Rollback structure of the Dept
statement frees the The Describe Dept table only if there is a
storage space statement returns an COMMITstatement
occupied by the error ORA-04043: object introduced before the
Dept table. Dept does not exist. ROLLBACK statement.
DECLARE TYPE
TimeTyprec IS
DECLARE TYPE RECORD ( minutes
TimeTyprec IS DECLARE TYPE DATE, hours DATE );
RECORD ( minutes TimeTyprec IS RECORD TYPE Meetingmode IS
DATE, hours ( minutes DATE, hours RECORD ( day DATE,
DATE ); TYPE DATE ); TYPE time_of TimeTyprec,
Meetingmode IS Meetingmode IS dept TBL_departments
RECORD ( day RECORD ( day DATE, %ROWTYPE, place
DATE, time_of time_of TimeTyprec, dept VARCHAR2(20),
TimeTyprec, dept TBL_departments purpose
TBL_departments %ROWTYPE, place VARCHAR2(50) ); TYPE
%ROWTYPE, place VARCHAR2(20), ToMeet IS RECORD
VARCHAR2(20), purpose VARCHAR2(50) ( day DATE, time_of
purpose ); TYPE ToMeet IS DATE, dept
VARCHAR2(50) ); RECORD ( day DATE, TBL_departments
meeting time_of TimeTyprec, dept %ROWTYPE, place
Meetingmode; TBL_departments VARCHAR2(20),
seminar %ROWTYPE, time purpose
Meetingmode; SMALLINT); meeting VARCHAR2(50) );
BEGIN Meetingmode; seminar meeting Meetingmode;
seminar.time_of := ToMeet; BEGIN seminar ToMeet; BEGIN
meeting.time_of; seminar.time_of := seminar.time_of :=
END; meeting.time_of; END; meeting.time_of; END;

Use Aggregate
function along with Use Aggregate function
WHERE clause in along with ORDER BY
query to retrieve clause in query to None of the listed
result retrieve result options
DECLARE
CURSOR c1 is
SELECT
employeeid,
firstname||','||
lastname "Name" ,
salary FROM
tbl_employees
ORDER BY salary
DESC; DECLARE CURSOR c1
v_employeeid is SELECT employeeid,
NUMBER; v_name firstname||','||lastname
VARCHAR2(30); "Name" , salary FROM
v_salary NUMBER; tbl_employees ORDER
BEGIN OPEN c1; BY salary DESC;
FOR i IN 1..4 LOOP v_employeeid NUMBER;
FETCH c1 INTO v_name VARCHAR2(30);
v_employeeid, v_salary NUMBER;
v_name, v_salary; BEGIN OPEN c1;
INSERT INTO temp FETCH c1 INTO
VALUES v_employeeid, v_name,
(v_employeeid, v_salary; INSERT INTO
v_name, v_salary); temp VALUES
EXIT WHEN (v_employeeid, v_name,
c1%NOTFOUND; v_salary); EXIT WHEN
COMMIT; END c1%NOTFOUND;
LOOP; CLOSE c1; COMMIT; END LOOP; None of the listed
END; CLOSE c1; END; options

Create Stored
Procedure Create index Create Trigger

FALSE
FALSE

FALSE

FALSE
DECLARE x
VARCHAR2 (5);
BEGIN SELECT BEGIN SELECT
dummy_var INTO x pkg_var.dummy_var
FROM DUAL; INTO x FROM DUAL;
DBMS_OUTPUT.pu DBMS_OUTPUT.put_line None of the listed
t_line (x); END; (x); END; options

FALSE

Factory Pattern Iterator Abstract Factory

FALSE

Model - View -
Controller Chain of Responsibility Bridge Pattern

FALSE
Factory Abstract Factory MVC

DAO Model - View - Controller Transfer Object

Decorator Pattern Composite Pattern Adapter Pattern

Structural Pattern Behavioral Pattern Non of the options

It increases the
complexity of the
remote interface and It increases the network
access by removing Minimizes the latency performance by
coarse grained and server resource introducing multiple fine
methods usage grained remote requests

Chain of
Responsibility
pattern Template Method Pattern MVC Pattern
Decorator Pattern Proxy Pattern Template Pattern

Software coupling
defined as the Cohesion is clear Cohesion is the OO
degree to which a separation of related principle most closely
software module functionality into distinct associated with
relies or depends on modules, Components , Cohesion maximizes allowing an object to
other modules. or classes. code reusability have many types

Factory Pattern Façade Service Locator


the implementation code
for Singleton pattern :
public class
PrinterSingleton { public
PrinterSingleton
instance = null; private
To implement singleton PrinterSingleton () { }
pattern, we create static public PrinterSingleton
reference to the singleton getInstance()
instance and return a { if(instance == null)
Provides global reference to that instance { instance = new ApplicationContext is
access to the from a static instance() PrinterSingleton (); } the example of
Singleton Object method return instance; } } Singleton Pattern

FALSE
AnswerD
Grade2 Grade3 Grade4 Grade5 escription QuestionMAnswerMedAuthor Reviewer Is Numeric
Is Numeric

You might also like