Java MCQ's
Java MCQ's
a) Statement
b) Connection
c) Driver
d) DriverManager
a) Class
b) Object...............
c) String
d) Super
a) abstract
b) final
c) static
a) True
b) False....
a) throws
b) throw.................
c) catch
d) try
9. The default thread model used by most of the web server for servlets is
a) Multithread model
c) no thread model
d) process model
b) (i), (ii)
c) (iii)
11. The synchronized modifier is used to control access to critical code in multithreaded
programs.
a) False
b) True
c) Ignore
d) Ignore
12. JNDI is
a) Naming service
b) directory interface
a) it asks server to return response headers only and not the complete resource.
c) HTML
15. java.io.Serializable is
16. The process of writing the state of an object to a byte stream, To save the state of your
program to a persistent storage area such as a file is called as _________.
a) Serialization, deserialization
b) deserialization, Serialization
c) Serialization, Externalization
17. Which of the following type of driver was widely used when JDBC was very new.
18. The JDBC API consists of some classes and some interfaces. Identify which out of the
b) CallableStatement
C) Connection
a) Built in JDK1.3
b) free of cost
c) easy to use
20. Which of the following will read a set of words from the command line?
a) System.in.read()
b) System.in.readLine()
a) The query to be executed is dynamic and it is not known whether it is select or update
statement.
22. In a pure java class the method is Static block is called before the main() method
a) True...
b) False
c) Ignore
d) Ignore
a) Number of Parameters
c) Return Type
a) True
b) False..............
c) NA
d) NA
a) Exception
b) Error
c) Throws
d) Throwable
26. ______________ is the "Block of code" that is always executed (normal execution)
b) Destructor
c) Finally
27. What is the modifier that for a method, so that only one thread can access it at a time, in a
multi-threading context
a) Final
b) Synchronized
c) Abstract
d) Static
a) run()
b) CreateThread()
c) main()
a) True
b) False
a) True
b) False
c) Always
c)Java is portable
(i) public class Myclass implements IA, IB, IC // IA, IB, IC are different interfaces
….
...
...
...
a) i
b)ii
d)NA
34. Which of these is the valid declarations for the main method?
a) public void main();
a) Servlet container
b) the client
c) Both a and b
c) Either a or b
39. In Java, when two or more threads need access to a shared resource,
_____is a way to ensure that the resource will be used by only one thread at a time.
a) creating a semaphore
b) Using mutex
c) Synchronization
41. Which of these is the valid declaration for the main method?
42. If no access modifier is specified in Java the default access modifier assumed is
a) private
b) public
c) protected
d) package level
43. In a try-catch-finally construct, the finally block is executed
c) Always
a) Thread Priority
b) Thread Running
a) java.awt package
b) java.applet package
c) java.sql package
d) java.net package
c) both a and b
a) awt
b) lang
c) util
d) jfc
48. Which of the following method is called when the Servlet is first loaded?
a) initialize() method
b) init() method****************************
a) Supports Multithreading
b) Platform independent
c) Protocol independent
a) Zero
b) One
c) Two
d) Three
b) Wrapper Class
c) Data Type
d) Constructor
53. The main interfaces that every Driver layer must implement are
a) Driver
b) Connection
c) Resultset
54. Commit() and RollBack() are methods belonging to which of the following classes?
a) Driver
b) Connection
c) Statement
d) ResultSet
******************************************************************************
******************************************************************************
************************************************************
55. The procees of ensuring that any shared resource is accessed by a single thread at a time is
called as
a) Multi-threading
b) Synchronization
c) Cloning
d) Serialization
56. The serialization process can be controlled using the _______________ interface
a) Externalizable
b) Serializable
c) ActionListener
d) Runnable
b) Any web server with built in Servlet engine / add on for the servlet
engine**********************
a) abstract
b) final
c) static
80. _________________ is the concept by which one class is inherited from more than one super
class
a) Multiple inheritance.....................
b) Mutilevel inheritance
c)Single inheritance
81. Class C is inherited from class A and class B,class D is inherited from class C; Which of the
following is true?
a)i, ii, v
c)ii, iii
d)i, iv
82. Will the following class compile? If yes what is the output?
class Envy
static int i;
Envy()
++i;
{
System.out.println(i);
class Employee
double salary;
d) Make salary private and define methods called getSalary() and setSalary()
84.
int x = 10, y;
if (x < 10) y =1 ;
if (x >=10) y =2 ;
Y is 1
Y is 2
85. What gets printed on the standard output when the class below is compiled and executed by
entering "java test This is a test"
a) TRUE...................
b) FALSE
a) Class
b) Object
c) Interface
d) Container
88. An abstract class can have static methods that are not abstract.
a) TRUE
b) FALSE
a) TRUE
b) FALSE
class JDBCDemo
try
Class.forName("oracle.jdbc.driver.OracleDriver");
Statement si = con.createStatement();
con.rollback();
con.close();
catch (Exception e)
System.err.println("Error!!");
}
}
b) One row will be inserted and then will be rolledback when program terminates normally
d) Will throw an error because executeUpdate() method cannot be used for inserts
91. In case an error occurs in the execution of a Oracle stored procedure from a Java program
92. You can make an object that reads and writes records from a database safe for multiple
clients by
94. Usually, Server Socket waits on a port for requests, and upon receiving a request, gives a
socket connection on the
a) same port
b) different port
a) Connectionless
b) Connection oriented
c) Either 1 or 2
d) Neither
a) Content-length
b) Cookies
97. What will happen when the code is compiled and executed?
import javax.servlet.http.*;
import java.io.*;
class TestServlet extends HttpServlet
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.close();
doGet(request, response);
a) Compilation Error
98. Method that is used to retrieve value from a session variable is (assuming session is an
object of HttpSession)
a) session.getValue("sessionvarname");
b) session.getAttribute("sessionvarname");***********************8
c) session.getDetails("sessionvarname");
d) Options a and b
a) False
b) True****************************
c) Invalid option
d) Invalid option
100. If the user opens two instances of browsers separately and accesses the same ASP
page, how many session objects will be created on the Application Server?
a)1
b)2
c)3
d)4
******************************************************************************
******************************************************************************
************************************************************
a) Private
b) Protected
c) Final
10. You can implement the selected methods of interface. This can be achieved by
a) inner class
c) Adapter class
b) Object References
c) Pointer itself
d) Classes
a) Finally block
b) Throws block
c) Try block
14. System.in can be used to directly read lines from the console
a) true
b) false
15. From OO point of view which of the following is better option for creating a thread
b) separately scheduled thread in the Java Virtual Machine, which then executes the code
c) separately scheduled thread in the operating system, which then executes the code
d) separately scheduled thread in the Java Virtual Machine, which then executes the code
17. For writing transactions, the Autocommit mode of the Connection object should be
made as true
a) True
b) False
19. ..
a) executeQuery()
b) executeUpdate()
c) execute()
d) getResultSet()
a) true
b) false*****************
c) can't say
a) current object.....................
23. In an Object-Oriented system, objects interact with each other by sending and receiving
____________________
a) arguments
b) messages
c) methods
d) None of these
24. Name the class that includes the getSession method that is used to get the HttpSession
object.
a) HttpServletResponse
b) HttpServletRequest
c) SessionContext
d) SessionConfig
25. The method getWriter returns an object of type PrintWriter. This class has println
methods to generate output. Which of these classes define the getWriter method? Choose
the correct option
a) HttpServletRequest
b) HttpServletResponse
c) ServletConfig
d) ServletContext
26. To send text output in a response, the following method of HttpServletResponse may be
used to get the appropriate Writer/Stream object. Choose the correct option.
a) getStream
b) getOutputStream
c) getBinaryStream
d) getWriter
27. Which method returns names of the request parameters as Enumeration of String
objects
a) getParameter
b) getParameterNames
c) getParameterValues
a) /lib/
b) /WEB-INF/classes/
c) /classes
d) /WEB-INF/lib/
a) A virtual function "paint" is defined in a base class called windows and each derived
classes SpreadSheetWindows, GraphWindows overrides the method paint
30. If I create and load all the dialogs (say 50 dialog) in an UI Application at the start up
into a dialog array and show and hide one dialog on a need basis, what do I achieve?
31. If I want to use JDBC code in my Java program what all I need to do
a) Include the jdbc class files in the CLASSPATH and import the relevant packages in the
program*****************
b) Just have the jdbc class files in the CLASSPATH and run the java program with the
classpath option
c) Just import the relevant JDBC packages in the program
d) Both 1 and 2
class Superclass{}
c) No error at all
a) b1==b2
b) b1.equals(b2)
c) both a & b
d) b1 | b2
a) Yes
b) No
a) Using classes
b) Using Objects.....................
c) Using pointers
36. What exception will be thrown from the code given below:
class Arr
ia[2] = 2;
System.out.println(ia[2]);
a) NullPointerException
b) ArrayIndexOutOfBoundsException....................
c) IllegalAccessException
37. What will happen when you attempt to compile and run the following code
public class Bground extends Thread
b.run();
a) A compile time error indicating that no run method is defined for the Thread class
b) A run time error indicating that no run method is defined for the Thread class
c) the programs compiles and runs correctly with values 0 to 9 printed out
c) Either 1 or 2***************************
39. If there are two threads with different priority, does that mean that higher-priority
thread will run faster than the lower priority thread
a) True
b) False******************************
40. If a thread has entered a synchronized method of an instance, another thread cannot
call any other methods (synchronized or non-synchronised) of the same instance.
a) True
b) False***********************
42. If a frame uses a grid layout manager and does not contain any panels,
a) then all the components within the frame are of different width and height
b) then all the components within the frame are the same width and height.
d) then all the components within the frame are not completely visible
1. try{
2. sleep(100);
3. } catch(InterruptedException e) { }
Assuming the thread is not interrupted, which one of the following statements is correct?
a) The code will not compile, because exceptions may not be caught in a threads run()
method.
b) At line 2, the thread will stop running. Execution will resume in atmost 100 milliseconds
c) At line 2, the thread will stop running. Execution will resume in exactly 100 milliseconds
d) At line 2, the thread will stop running. Execution will resume in some time after 100
milliseconds have elapsed.
super();
class constructor
constructor
b) [i], [ii],[iii]
c) [i], [ii]
d) [i], [ii],[iv]
There are methods, System.gc() and Runtime.gc() that look as of they run
tehthe garbage collector but even these methods do not have any control on
a) False
b) True
a) Java contains many subsystems that work only with objects and not
c) They can encapsulate the power of the functions related with something
c) is Serializable b
49. If one needs to find out what are the methods of one object/class
by reading a .class file(without having .java file) what way/API can help
a) API cannot do this work, you must have a specialized software for this.
50. What happens when object of the file class is garbage collected
c) file is not deleted but the reference to the file is not available
anymore.
51. Which of the following statements are correct regarding the Object
class in Java
[ii] when you want to write a generic method which needs to accept any
c) [i], [ii]
d) [i], [iii]
52. Which of the following is true about the abstract classes and interface
be implemented to be usable.
53. Which of the following class can be used to find out the ipaddress of
your machine?
a) IpAddress
b) InetAddress**********************
c) NetAddress
54. Which one of the following object contains the description of the
current resultset.
a) ResultSet Object.
b) MetaData Object.
c) ResultSetMetaData Object***************************
of bytes
d) all of the above
implemented using
c) created while using JdbcOdbc bridge driver from the java program
[i] block
[ii] method
[iii] object
[iv] class
a) only [ii]
b) [ii], [iii]*********************
Naming.rebind method
d) both c and b
61. In Java, when two or more threads need access to a shared resource,
_____is a way to ensure that the resource will be used by only one
thread at a time.
a) creating a semaphore
b) Using mutex
c) Synchronization***********************
b) Database access
c) Transactions
SingleThreadModel interface
d) a first to-be loaded servlet and is loaded by the server during startup
a) i only
b) i, ii, iii
c) i and ii only
c) iii only
67. What access control keyword should you use to enable other classes to access a method
freely within its package,but to restrict classes outside of the package from accessing that
method?
a) private
b) public
c) protected
a) True
b) False
c) both of these
a) all methods
71. Which of the following tools is used to generate the stubs and skeletons
a) javac
b) rmic
c) java
d) rmiregistry
72. What interface must a class inherit from before an object of that type could be written
to a stream?
a) Serializable **********************
b) Remote
73 Looking at the following piece of the code, Select the correct statement out of the given
options
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
c) Usually written in the init() method of Servlet to load the driver into
memory************* ????????????
c) both
a) Interfaces
b) classes
c) abstract classes
d) extends keyword
a) True
b) False
77. What is the main disadvantages of using Java vis-à-vis C/C++ language
78. In case an error occurs in the execution of a Oracle stored procedure from a Java
program
79. Inside the interface, while declaring a function that others can access remotely,you must
extend which interface?
a) Cloneable
b) Serializable
c) RemoteObject
d) Remote
c) Always
a)Instance variables
b)static variables************************
c)public variables
d)final variables
a)Apache server
b)IIs
d)Tomcat Server********************8
a) JButton****************
b) Dialog
c) ScrollPane
d) Panel
tThrd.start();}
System.out.println("hi");
}
}
a) This program compiles and word ""hi"" appears in the standard output (once)."
b) This program compiles and word ""hi"" appears continuously in the standard output
until the user hits Ctrl+C to stop the program."
c) compilation error***********************
d) runtime error
86. The URL in the POST method can be used to find out the query parameters
a) true
b) false
a) Writing a function in the child class, which has the same name and same function
signature as that of the function in the parent class is called overriding.
c) Writing a function in the child class, which has the same name but different function
a) public method();
a) .jar file
b) .class file
c) .java file
d) .exe file
d) both a,b
94. A ______ is a part of JVM that loads all classes that are required for the execution of
the java program.
a) JRE
b) bytecode loader
c) class verifier
d) classloader
95. Which one of the following interface is used to call a stored procedure from java
a) StoredCall
b) CallProcedure
c) CallableStatement
96. The lowest level synchronization which synchronizes the smallest unit is
a) synchronizing a method
b) synchronizing a object
c) synchronizing a block
d) synchronizing a class
c) rmiregistry has to be running for the client to get handle of the remote object
98. The following code which is saved in c:\test.java. Choose the appropriate statement
which will compile it and do the placement of the bytecode accurately.
package mypackage;
a) c:\>javac -d . test.java
99. The capability of an object to exist beyond the execution of the program that created it
its indicated by inherting from
a) Serializable interface
b) Remote interface
101. Select which of the following is the best place to close the connection in the simple java
code
a) try block
b) catch block
c) finally block
103. From OO point of view which of the following is better for creating a thread
d) implement Runnable**********************
105. _________ translates the standard JDBC calls into the specific calls required by the
database it supports.
a) JVM
b) Drivermanager
c) Driver
106. If we have not created a DSN for the database, it is possible to access this database
from Java?
a) Yes
b) No
b) EJB
c) CORBA objects
d) JNDI
/******************************************************
a)Although webservers can be configured to ports other than 80 for http requests, it is fine
to configure them to 8000 in production environments
b)Although webservers can be configured to ports other than 80 for http requests, it is not
fine to configure them to 8000 in production environments
c)Webservers do not allow you to configure to ports other than 80 and 443
2. The following method is used to create a PrintWriter object that can be used to write text
to the response
a) getWriter() ------
b) getOutputStream()
c) getBinaryStream()
d) getStream()
3. The service() method has objects of these classes as parameters - HttpServletRequest and
HttpServletResponse
a) True
b) False---------
import javax.servlet.http.*;
import java.io.*;
int var;
var=0;
....
For every browser request, a new instance of the servlet is created by the server
a) True
b) False
5. Name the class that can be used to get the cookies from the client browser
a) HttpServletResponse
b) HttpServletRequest---------
c) SessionContext
d) SessionConfig
a) Servlets
b) Java Server Pages
c) DHTML---------
d) CGI
7. Which method returns an array of String objects containing all of the values the given
request parameter has
a) getParameter()
b) getParameterNames()
c) getParameterValues()------
a) 1 is true
b) 2 is true
a) Private
b) Protected
c) Final
10. You can implement the selected methods of interface. This can be achieved by
a) inner class
b) Anonymous inner class
c) Adapter class
b) Object References
c) Pointer itself
d) Classes
a) Finally block
b) Throws block
c) Try block
14. System.in can be used to directly read lines from the console
a) true
b) false
--a) True
b) false
c) Ignore
d) Ignore
2. ASP Scripting
b) One can set client side cookies by using the request.Cookies indexed property
c) AUTH_TYPE server variable is used to find out the type of author of the web page.
9.Which method is used to transfer the request from the client to another location?
a) Flush
--b) Redirect
c) End
d) Clear
--a) True
b) false
c) Ignore
d) Ignore
21. As far as Server side functionality is concerned, the GET method is more secure that
the POST method in the sense that form actions are not repeated for repeated invocations.
--a) TRUE
b) FALSE
b) Request Object
--a) TRUE
b) FALSE
27. How can a servlet can call a HTML document & pass data to it? Passing data is
important.
a) request.sendRedirect("something.html?required_parameters")
--c) Servlet can write HTML to response object, but cannot pass parameters
*************************************
ORACLE
1. :new and :old cannot be used with statement level triggers in Oracle
a)True **
b)False
c)NA
d)NA
2. Whenever user issues insert,update or delete statement on the table Oracle implicitly
locks
the table in
a) Once the object is created we cannot modify the attributes and methods of a type
b) Once the object is created we cannot modify the attributes of a type but we can modify
the
c)we can modify the attributes and methods of a type even if objects are created. .
d)we can modify the attributes but we cannot modify the methods of a type once the object
is
created.
a)When any of the DML statement fetches more than one row from the table **
b) when select statement fetches more than one row from the table
c) when select statement fetches more than one row from the table or cannot fetch any row
from
the table.
d) a and c
c)both a) and b) **
a)-20000 to -20999 **
b)20000 to 20999
7. PGA is created
a)TRUE
b)FALSE **
c)NA
d)NA
9. if checkpoint is not enabled which of the following process does the job of a checkpoint.
a)DBWR
b)LGWR **
c)SMON
d)PMON
10. I want to store Employee number , Employee Photograph and Employee description
(having data
declare
X number := NULL;
Y number := NULL;
begin
if X=Y then
else
dbms_output.put_line('Unknown result');
end if;
end;
c) Unknown result **
b) Row level triggers have access to the :new and :old records
c) Triggers are fired automatically
13. Following is the sequence of queries executed via SQL PLUS on an ORACLE 8i
database.
(v) ROLLBACK;
(vi) COMMIT;
After executing the above statements in order, which of the following statement is true
a) After step (vi), the table COUNTS will have only COL1 and the value will be NULL
b) After step (vi), the table COUNTS will have only COL1 and the value will be 5
c) After step (vi), the table COUNTS will have NULL in both COL1 and COL2
d) After step (vi), the table COUNTS will have value ‘5’ in COL1 and NULL in COL2 **
a) Current day
15. Which one of the below list is not a SQL *plus command
a) SPOOL
b) STOP **
c) EXIT
d) SAVE
a) CLOB **
b) BLOB
c) BFILE
BC
66
77
88
select rownum
from Temp1
order by B desc;
a) 6 7 8
b) 8 7 6
c) 1 2 3
d) 3 2 1 **
19. Maximum what size of binary data can be stored in BLOB datatype?
a) 1 GB
b) 2 MB
c) 4 MB
d) 4 GB **
20. The memory structure that does not constitute the ORACLE instance is
b) Dictionary Cache
d) None Of these **
a) TRUE **
b) FALSE
c) NA
d) NA
22. Indexing
a) Speedens Inserts
b) Speedens updates
24. if checkpoint is not enabled which of the following process does the job of a checkpoint.
a) DBWR
b) LGWR **
c) SMON
d) PMON
a) Indexes
b) Clusters
c) Both a and b **
a) DatabaseTrigger
b) Stored procedure
c) Function
a) Procedures
b) Functions
c) Both a and b **
29. When one user is waiting for data locked by another user,
a) dirty read
b) phantom record
c) deadlock
30. The memory structure that does not constitute the ORACLE instance is
b) Dictionary Cache
d) Both a and b **
32. Which of the following query returns the current date
33. An object table is a special kind of table that holds objects and provides a relational
view
of the
a) True **
b) False
c) Not Applicable
d) Not Applicable
34. Which Static data dictionary view describes the columns of tables, views and clusters
owned
a) COLS
b) USER_COLL_TYPES
c) USER_CONS_COLUMNS
d) USER_IND_COLUMNS
35. How do you drop a user (say Anil) from the database with all the objects/resources
owned by
him?
36. A Join condition involving an operator other than the equivalency is called
a) Non EquiJoin **
b) EquiJoin
c) OuterJoin
d) Inner Join
37. When an Oracle Database is started, memory is set aside and one or more processes are
started
a) True **
b) False
c) Not Applicable
d) Not Applicable
a) DataBase Writer(DBWR)
b) Log Writer(LGWR)
c) System Monitor(SMON)
a) NULL
b) 8070
c) 420
d) 7650
40. When a transaction reads an uncommitted data of other transaction, this will lead to
a) Phantom read
b) Dirty read **
c) Lost update
41. A foreign key whose values are required to match the values of candidate key in the
same
a) composite keys
c) overlapping keys
42. Choose the correct answers to SELECT the list of values in column COL1 from 1 to 3
from a
d) select COL1 from X where COL1 not <= 1 and not >= 3
43. :new and :old cannot be used with statement level triggers in Oracle
a)True **
b)False
c)NA
d)NA
44. Whenever user issues insert,update or delete statement on the table Oracle implicitly
locks
the table in
45.In Oracle One control file is associated with only one database.
a)true **
b)false
c)NA
d)NA
46. Which of the following situation in a PL/SQL block leads to too_many_rows exception.
a)When any of the DML statement fetches more than one row from the table
b) when select statement fetches more than one row from the table **
c) when select statement fetches more than one row from the table or cannot fetch any row
from
the table.
d) a and c
c)both a) and b)
b)20000 to 20999
a)TRUE
b)FALSE **
c)NA
d)NA
51. Indexing
a)Speedens Inserts
b)Speedens updates
52. Can the function MAX be used on columns having DataType as Char?
a)TRUE **
b)FALSE
c)NA
d)NA
53. Assume you have a Database Table, which is used for storing historical Data. This table
most
of the time is used for reading data from it and generating reports. Will higher level of
Normalization ( > 2 NF) would necessarily lead to better retrival of the data contained in
the
table?
a)YES
b)No **
a)True
b)False **
a)SUM **
b)ORDER BY
c)HAVING
d)ASC
a)Predicate logic
d)Graph theory
BEGIN
BEGIN
A:=1;
B:=2;
END;
dbms_output.put_line('A'||'A');
dbms_output.put_line('B'||'B');
END;
a) 1 and 2
b) A is blank and B is 2
c) A is 1 and B is blank
d) Gives Error **
SELECT to_date('25-SEP-2002','mm/dd/yyyy')
FROM dual;
a) 09/25/2002
b) 9/25/2002
c) 25/9/2002
d) Gives Error
c) Because there are less chance of hangs because of shortage of rollback segments
d) Because partial failure in the longer ones would result in inconsistent results
61. A view gets updated automatically when a table gets updated in Oracle.
a) True **
b) False
c) Ignore this option
62. A table can contain more than one column having LONG data type
a) True
b) False **
63. The database object that is used to provide improved performance in the retrieval of
rows
from a table is
a) Synonym
b) Index **
c) Sequence
d) Trigger
64. If there is no exception handler for the raised exception in the current block then
a) only 1 is true
b) only 2 is true
DECLARE
ex1 EXCEPTION;
...
BEGIN
...
DECLARE
...
...
BEGIN
...
RAISE ex1;
...
EXCEPTION
...
END;
...
...
EXCEPTION
...
...
END;
a) Execution will resume in the inner block from the statement after the error-causing
statement
b) Execution will resume from the next executable statement after the end of the inner
block **
66. declare
v_result boolean;
begin
v_result:=SQL%ISOPEN;
commit;
end;
a) 0
b) 3
c) true
d) false **
Transaction1 has UPDATED row1 of table1 but has not committed as yet
a) Transaction 2 will be asked to wait till Transaction 1 releases the lock on row1
b) Transaction 2 will be given an implicit Shared lock before it could SELECT row1
c) Transaction 2 will be allowed to SELECT row1 reflecting values which is a result of the
68. The data dictionary view which maintains the constraints imposed on the objects
created
by a user:
a) constraints_users
b) constraint_name
c) users_constraint
d) user_constraints **
DECLARE
CURSOR empCursor IS
BEGIN
dbms_output.put_line(empCurRec.EmpNo);
END LOOP;
END;
b) There is no Fetching operation, so no record will be fetched, but the code will compile.
d) There is no error in the code. It will fetch all the records from the table and display the
empnos. **
70. With respect to execution of the DDL commands in PL/SQL, which one of the following
is true?
71. Assume that there is a table called EMP with following columns - EMPNO, ENAME,
ESAL
without any primary key. What will be output if we execute the following SQL statement 5
times-
b) Only 1 record will be inserted with NULL stored in all the columns
c) Only 1 record is created and the system assigns some unique value to the EMPNO
column
automatically
d) Both a & b
74. All candidate keys except primary key are foreign keys
a) True
b) False
a) ERROR
a) Foreign Key
b) Primary Key **
c) Candidate Key
79. The correct way to get the next value of a sequence into a PL/SQL variable (assuming
the
a) iTest := seqTest.NEXTVAL
d) iTest := seqTest.CURRVAL
80. In the PL/SQL block given below, how many times will the loop be executed ?
BEGIN
FOR i in 1..50
LOOP
i:=i+1;
END;
a) 10 times
b) 25 times
c) Once
81. Choose the correct answer with respect to the statements given below
I] Functions cannot have out parameter as they already have a return type
II] Functions cannot return more than one value by any means
a) Only I is true
c) only II is true
PRAGMA EXECEPTION_INIT(EX1,-20000)
******************************************
SERVLETS
a) Servlet container********************
b) the client
c) Both a and b
2.Which of the following method is called when the Servlet is first loaded?
a) initialize() method
b) init() method****************************
a) Supports Multithreading
b) Platform independent
c) Protocol independent
b) Any web server with built in Servlet engine / add on for the servlet
engine**********************8
a) it asks server to return response headers only and not the complete
resource.***********
a) Content-length
b) Cookies
import javax.servlet.http.*;
import java.io.*;
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.close();
}
doGet(request, response);
a) Compilation Error
9. Method that is used to retrieve value from a session variable is (assuming session is an
object of HttpSession)
a) session.getValue("sessionvarname");
b) session.getAttribute("sessionvarname");
c) session.getDetails("sessionvarname");
a) False
b) True****************************
c) Invalid option
d) Invalid option
11.If the user opens two instances of browsers separately and accesses the same ASP page,
how many session objects will be created on the Application Server?
a)1*************
b)2
c)3
d)4
a)Although webservers can be configured to ports other than 80 for http requests, it is fine
to configure them to 8000 in production environments
b)Although webservers can be configured to ports other than 80 for http requests, it is not
fine to configure them to 8000 in production environments**************
c)Webservers do not allow you to configure to ports other than 80 and 443
13.The following method is used to create a PrintWriter object that can be used to write
text to the response
a) getWriter()***************************
b) getOutputStream()
c) getBinaryStream()
d) getStream()
a) True*****************
b) False
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
int var;
var=0;
....
For every browser request, a new instance of the servlet is created by the server
a) True
b) False*****************
16.Name the class that can be used to get the cookies from the client browser
a) HttpServletResponse
b) HttpServletRequest************
c) SessionContext
d) SessionConfig
a) Servlets
c) DHTML*************
d) CGI
18.Which method returns an array of String objects containing all of the values the given
request parameter has
a) getParameter()
b) getParameterNames()
c) getParameterValues()************
19.Name the class that includes the getSession method that is used to get the HttpSession
object.
a) HttpServletResponse
b) HttpServletRequest***************
c) SessionContext
d) SessionConfig
20.The method getWriter returns an object of type PrintWriter. This class has println
methods to generate output. Which of these classes define the getWriter method? Choose
the correct option
a) HttpServletRequest
b) HttpServletResponse **************
c) ServletConfig
d) ServletContext
21.To send text output in a response, the following method of HttpServletResponse may be
used to get the appropriate Writer/Stream object. Choose the correct option.
a) getStream
b) getOutputStream
c) getBinaryStream
d) getWriter ****************
22. Which method returns names of the request parameters as Enumeration of String
objects
a) getParameter
b) getParameterNames
c) getParameterValues
23.Servlets classes specific to your application are placed in which directory on the
TOMCAT Server?
a) /lib/
b) /WEB-INF/classes/****************
c) /classes
d) /WEB-INF/lib/
implemented using
b) Database access
c) Transactions
SingleThreadModel interface
d) a first to-be loaded servlet and is loaded by the server during startup
a) i only
b) i, ii, iii*****************
c) i and ii only
c) iii only
30.Looking at the following piece of the code, Select the correct statement out of the given
options
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
c) Usually written in the init() method of Servlet to load the driver into
memory************
c) both**************
a)Apache server
b)IIs
c)Windows 2000 Server
d)Tomcat Server********************8
33.The URL in the POST method can be used to find out the query parameters
a) true
b) false