pra mcq tcs
pra mcq tcs
executeQuery()
execute()
executeUpdate()
executeInsert()
executeInsert()
execute()
executeUpdate()
executeQuery()
Statement
PreparedStatement
ResultSet
DriverManager
8. Consider the following code snippet:
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM
Students");
What will the "rs" object contain after executing the
above lines?
10. How can you fetch the value of the second column
as a string from a "ResultSet" object named "rs"?
rs.getString(2);
rs.getInt("column_name");
rs.getColumn(2);
rs.getValue(2);
Vehicle is running
Bike is running
Compilation error
None of the above
A
B
Both A and B
Compilation error due to ambiguity
Red
Green
Blue
An IndexOutOfBoundsException
One
Two
Three
Null
10/0
An unhandled exception message
Arithmetic Exception Caught
No output
imports
implements
extends
inherits
public
restricted
protected
private
18. When is a method said to be overloaded?
HashSet
LinkedList
Array
ArrayList
Values
Keys
Both keys and values
Neither keys nor values
JSP Expression
JSP Scriptlet
JSP Declaration
JSP Comment
${param.username}
${request.getParameter.username}
<%= request.getParameter("username") %>
Both A and C
doGet()
doPost()
doExecute()
doRequest()
Welcome
Welcome to Servlets
An error message
The current date and time
/WebContent
/src
/lib
/META-INF
RuntimeException
CompilationError
ExceptionHandled
None of the above
getMessage()
printStackTrace()
toString()
getDescription()
Method 1
Method 2
Method 3
Method 4
34. what will be the output of following code after
Execution ?
class Animal {
void makeSound() {
System.out.println("Animal makes a sound");
}
}
class Lion extends Animal {
void makeSound() {
System.out.println("Lion roars");
}
}
class Dog extends Animal {
void makeSound() {
System.out.println("Dog Barks");
}
}
public class DemoClass{
public static void main(String[] args) {
Animal animal1 = new Lion();
Animal animal2 = new Dog();
animal1.makeSound();
animal2.makeSound();
}
}
Lion roars
Dog Barks
Dog Barks
Lion roars
Animal makes a sound
Lion roars
Dog Barks
Lion roars
Dog Barks
Animal makes a sound
ArrayIndexOutOfBoundException
ClassCastException
InputMismatchException
[Chennai, Mumbai, Kolkata, Bangalore]
ArrayIndexOutOfBoundException
ClassCastException
InputMismatchExceptio
[Chennai, Mumbai, Kolkata, Bangalore]
connect( )
openConnection( )
getConnection( )
createConnection( )
shutdown()
close()
endconnection()
disconnect()
SQLException
DatabaseException
ConnectionException
ConnectivityException
Class.forName("org.mysql.jdbc.EmbeddedDriver");
con=DriverManager.getConnection("jdbc:derby:C:\\Us
er\\MyDB;create=true");
Class.forName("org.apache.derby.jdbc.EmbeddedDrive
r");
con=DriverManager.getConnection("jdbc:derby:C:\\Us
er\\MyDB;create=true");
Class.forName("org.apache.derby.jdbc.EmbeddedDrive
r");
con=DriverManager.getConnection("derby:C:\\User\\
MyDB;create=true");
Class.forName("org.apache.derby.jdbc.EmbeddedDrive
r");
con=DriverManager.getConnection("jdbc:C:\\User\\My
DB;create=true");
request.getSession()
response.getSession();
new Session()
None of the above
2.02E+11
20
15
None of the above
session.getAttribute(String name)
session.alterAttribute(String name)
session.updateAttribute(String name)
session.setAttribute(String name)
56. Which of the following is stored at client side?
URL rewriting
Hidden form fields
SSL sessions
Cookies
<jsp:forward>
<%@directive%>
response.sendRedirect(URL)
response.setRedirect(URL)
page directive
include directive
taglib directive
command directive
request.getParameter()
request.setParameter()
response.getParameter()
response.getAttribute()
HashSet
LinkedHashSet
TreeSet
PriorityQueue
try
finally
thrown
catch
NullPointerException
ArithmeticException
ClassNotFoundException
IOException
Hybrid Inheritance
Simple Inheritance
Multi level Inheritance
Multiple Inheritance
FileNotFoundException
OutOfMemoryError
NullPointerException
CustomOutOfStockException
HashSet
ArrayList
TreeSet
HashMap
69. Which of the following is a valid way to create a
new file in Java?
File myfile = new File("myfile.txt");
FileWriter myfile = new FileWriter("myfile.txt");
PrintWriter myfile = new PrintWriter("myfile.txt");
Scanner myfile = new Scanner("myfile.txt");
executeResult()
executeQuery()
executeUpdate()
execute()
Class.forName("org.mysql.jdbc.EmbeddedDriver");
con=DriverManager.getConnection("jdbc:derby:C:\\
User\\MyDB;create=true");
Class.forName("org.sqlite.JDBC");
con=DriverManager.getConnection("jdbc:sqlite:C:\\
User\\MyDB");
Class.forName("org.apache.derby.jdbc.EmbeddedDr
iver")
con=DriverManger.getConnection("derby:C:\\User\\
MyDB;create=true")
Class.forName("org.apache.derby.jdbc.EmbeddedDi
ver");
con=DriverManager.getConnection("jdbc:C:\\User\
MyDB;create=true");
RequestDispatcher rd =
req.getRequestDispatcher("Welcome.html");
rd.forward(req, resp);
Hi Welcome to Validate Servlet Contents of
Welcome.html
Hi Welcome to Validate Servlet
Contents of Welcome.html
None of the above