0% found this document useful (0 votes)
249 views26 pages

Java & Web Tech MCQs for Students

This document contains 40 multiple choice questions about Java programming concepts. The questions cover topics like the Java Development Kit (JDK), Java Virtual Machine (JVM), bytecode, identifiers, HTTP, arrays, operators, control flow, exceptions, inheritance, threads, applets and more. Each question is followed by 4 possible answer choices.

Uploaded by

youtube
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
249 views26 pages

Java & Web Tech MCQs for Students

This document contains 40 multiple choice questions about Java programming concepts. The questions cover topics like the Java Development Kit (JDK), Java Virtual Machine (JVM), bytecode, identifiers, HTTP, arrays, operators, control flow, exceptions, inheritance, threads, applets and more. Each question is followed by 4 possible answer choices.

Uploaded by

youtube
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Web Technology (KCS-602) - MCQ

Q. No. Questions
Which component is used to compile, debug and execute java program?
(A) JVM
1 (B) JDK
(C) JIT
(D) JRE
Which statement is true about java?
(A) Platform independent programming language
2 (B) Platform dependent programming language
(C) Code dependent programming language
(D) Sequence dependent programming language
Which component is responsible for converting bytecode into machine specific code?
(A) JVM
3 (B) JDK
(C) JIT
(D) JRE
Which of the below is invalid identifier with the main method?
(A) public
4 (B) static
(C) private
(D) final
How can we identify whether a compilation unit is class or interface from a .class file?
(A) Java source file header
5 (B) Extension of compilation unit
(C) We cannot differentiate between class and interface
(D) The class or interface name should be postfixed with unit type
What is use of interpreter?
(A) They convert bytecode to machine language code
6 (B) They read high level code and execute them
(C) They are intermediated between JIT and JVM
(D) It is a synonym for JIT
What is the return type of Constructors?
(A) int
7 (B) float
(C) void
(D) none of the mentioned
www is based on which model?
(A) Local-server
8 (B) Client-server
(C) 3-tier
(D) None of these
Which of the following is a Valid Name?
(A) <_person>
9 (B) <123 person>
(C) Both (a) and (b)
(D) None of these
Which of the following statements is true regarding HTTP?
(A) Web browsers use only HTTP as a communication protocol with servers
10 (B) It does not maintain any connection information on previous transactions
(C) It is designed to route information based on content
(D) It refers to resources using their Universal Resource Identifier (URI)
The web standard allows programmers on many different computer platforms to dispersed
format and display the information server. These programs are called
(A) Web Browsers
11
(B) HTML
(C) Internet Explorer
(D) None of these
The web standard allows programmers on many different computer platforms to dispersed
format and display the information server. These programs are called
(A) Web Browsers
12
(B) HTML
(C) Internet Explorer
(D) None of these
Which of these is an incorrect array declaration?
(A) int arr[] = new int[5]
13 (B) int [] arr = new int[5]
(C) int arr[] = new int[5]
(D) int arr[] = int [5] new
Which of these is an incorrect Statement?
(A) It is necessary to use new operator to initialize an array
(B) Array can be initialized using comma separated expressions surrounded by curly
14
braces
(C) Array can be initialized when they are declared
(D) None of the mentioned
What will be the output of the following Java code?

class array_output
{
public static void main(String args[])
{
int array_variable [] = new int[10];
for (int i = 0; i < 10; ++i)
{
15 array_variable[i] = i;
System.out.print(array_variable[i] + " ");
i++;
}
}
}
(A) 0 2 4 6 8
(B) 1 3 5 7 9
(C) 0 1 2 3 4 5 6 7 8 9
(D) 1 2 3 4 5 6 7 8 9 10
Modulus operator, %, can be applied to which of these?
16 (A) Integers
(B) Floating – point numbers
(C) Both Integers and floating – point numbers
(D) None of the mentioned
With x = 0, which of the following are legal lines of Java code for changing the value of x to
1?

1. x++;
2. x = x + 1;
17 3. x += 1;
4. x =+ 1;
(A) 1, 2 & 3
(B) 1 & 4
(C) 1, 2, 3 & 4
(D) 3 & 2
What will be the output of the following Java program?

class increment
{
public static void main(String args[])
{
double var1 = 1 + 5;
double var2 = var1 / 4;
int var3 = 1 + 5;
18
int var4 = var3 / 4;
System.out.print(var2 + " " + var4);

}
}
(A) 1 1
(B) 0 1
(C) 1.5 1
(D) 1.5 1.0
What would be the output of the following code snippet if variable a=10?

if(a<=0)
{
if(a==0)
{
System.out.println("1 ");
}
else
19
{
System.out.println("2 ");
}
}
System.out.println("3 ");
(A) 1 2
(B) 2 3
(C) 1 3
(D) 3
20 What is true about a break?
(A) Break stops the execution of entire program
(B) Break halts the execution and forces the control out of the loop
(C) Break forces the control out of the loop and starts the execution of next iteration
(D) Break halts the execution of the loop for certain time frame
What is the valid data type for variable “a” to print “Hello World”?
switch(a)
{
System.out.println("Hello World");
}
21
(A) int and float
(B) byte and short
(C) char and long
(D) byte and char
Which function is used to perform some action when the object is to be destroyed?
(A) finalize()
22 (B) delete()
(C) main()
(D) none of the mentioned
Which of the following statements are incorrect?
(A) default constructor is called at the time of object declaration
23 (B) constructor can be parameterized
(C) finalize() method is called when a object goes out of scope and is no longer needed
(D) finalize() method must be declared protected
Which of this keyword must be used to inherit a class?
(A) super
24 (B) this
(C) extent
(D) extends
Which of these is correct way of inheriting class A by class B?
(A) class B + class A {}
25 (B) class B inherits class A {}
(C) class B extends A {}
(D) class B extends class A {}
What will be the output of the following Java program?

class A
{
int i;
void display()
{
System.out.println(i);
26
}
}
class B extends A
{
int j;
void display()
{
System.out.println(j);
}
}
class inheritance_demo
{
public static void main(String args[])
{
B obj = new B();
obj.i=1;
obj.j=2;
obj.display();
}
}
(A) 0
(B) 1
(C) 2
(D) Compilation Error
Which of the following keywords is used for throwing exception manually?
(A) finally
27 (B) try
(C) throw
(D) catch
Which of the following keyword is used by calling function to handle exception thrown by
called function?
(A) throws
28
(B) throw
(C) try
(D) catch
At runtime, error is recoverable.
29 (A) True
(B) False
Which of these is a super class of all exceptional type classes?
(A) String
30 (B) RuntimeExceptions
(C) Throwable
(D) Cacheable
Which of these handles the exception when no catch is used?
(A) Default handler
31 (B) finally
(C) throw handler
(D) Java run time system
What is the use of try & catch?
(A) It allows us to manually handle the exception
32 (B) It allows to fix errors
(C) It prevents automatic terminating of the program in cases when an exception occurs
(D) All of the mentioned
Which of these keywords are used for the block to handle the exceptions generated by try
block?
33 (A) try
(B) catch
(C) throw
(D) check
Which of these statements is incorrect?
(A) try block need not to be followed by catch block
34 (B) try block can be followed by finally block instead of catch block
(C) try can be followed by both catch and finally block
(D) try need not to be followed by anything
What will be the output of the following Java code?

class Output
{
public static void main(String args[])
{
try
{
int a = 0;
int b = 5;
int c = b / a;
System.out.print("Hello");
}
35 catch(Exception e)
{
System.out.print("World");
}
finally
{
System.out.print("World");
}
}
}
(A) Hello
(B) World
(C) HelloWOrld
(D) WorldWorld
What does AWT stands for?
(A) All Window Tools
36 (B) All Writing Tools
(C) Abstract Window Toolkit
(D) Abstract Writing Toolkit
What is true about threading?
(A) run() method calls start() method and runs the code
37 (B) run() method creates new thread
(C) run() method can be called directly without start() method being called
(D) start() method creates new thread and calls code written in run() method
Which of the following is a correct constructor for thread?
(A) Thread(Runnable a, String str)
38 (B) Thread(int priority)
(C) Thread(Runnable a, int priority)
(D) Thread(Runnable a, ThreadGroup t)
Which of these functions is called to display the output of an applet?
39
(A) display()
(B) paint()
(C) displayApplet()
(D) PrintApplet()
What is the Message is displayed in the applet made by the following Java program?

import java.awt.*;
import java.applet.*;
public class myapplet extends Applet
{
public void paint(Graphics g)
40 {
g.drawString("A Simple Applet", 20, 20);
}
}
(A) A Simple Applet
(B) A Simple Applet 20 20
(C) Compilation Error
(D) Runtime Error
From which tag the descriptive list starts?
(A) <LL>
41 (B) <DD>
(C) <DL>
(D) <DS>
The latest HTML standard is
(A) XML
42 (B) SGML
(C) HTML 4.0
(D) HTML 5.0
HTML stands for?
(A) Hyper Text Markup Language
43 (B) High Text Markup Language
(C) Hyper Tabular Markup Language
(D) None of these
HTML is a subset of
(A) SGMT
44 (B) SGML
(C) SGMD
(D) None of these
The body tag usually used after
(A) Title tag
45 (B) HEAD tag
(C) EM tag
(D) FORM tag
Which of the following tag is used to mark a beginning of paragraph?
(A) <TD>
46 (B) <br>
(C) <P>
(D) <TR>
What are Empty elements and is it valid?
47
(A) No, there are no such terms as Empty Element
(B) Empty elements are element with no data
(C) No, it is not valid to use Empty Element
(D) None of these
Which method of the Component class is used to set the position and size of a component in
JSP?
(A) setSize()
48
(B) setBounds()
(C) setPosition()
(D) setPositionSize()
How can you open a link in a new browser window?
(A) < a href = "url" target = "new">
49 (B) <a href = "url" target= "_blank">
(C) <a href = "url".new>
(D) <a href = "url" target ="open">
The tag used to create a hypertext relationship between current document and another URL is
(A) <ISINDEX>
50 (B) <A>
(C) <LINK>
(D) None of these
Which tag creates a number/order list?
(A) <UL>
51 (B) <OL>
(C) <OT>
(D) None of these
Markup tags tell the web browser
(A) How to organize the page
52 (B) How to display the page
(C) How to display message box on page
(D) None of these
Which of the following is true about XHTML?
(A) It is a new hybrid technology that is different from both XML and HTML
53 (B) It has totally replaced HTML as the tool for building Web pages
(C) It is a reformulation of HTML in XML
(D) One cannot use it to create Web pages
Which of the following options is correct with regard to HTML?
(A) It is a modeling language
54 (B) It is a DTP language
(C) It is a partial programming language
(D) It is used to structure documents
How can you make an e-mail link?
(A) <mail href +"[email protected]">
55 (B) <a href ="mail to: [email protected]">
(C) <a href = "[email protected]">
(D) Both (b) and (c)
Correct HTML tag for the largest heading is
(A) <head>
56 (B) <h6>
(C) <heading>
(D) <h1>
57 Web pages starts with which of the following tag?
(A) <Body>
(B) <Title>
(C) <HTML>
(D) <Form>
Correct HTML to left align the content inside a table cell is
(A) <tdleft>
58 (B) <td raligh = "left" >
(C) <td align = "left">
(D) <td leftalign>
Which property does one use to align text to the right side of a block-level element in
Cascading Style Sheets?
(A) Horizontal-align
59
(B) Align
(C) Block-align
(D) Text-align
When trying to access a URL, the following message is displayed on the browser:
Server; Error 403

What could be the reason for the message?


60
(A) The requested HTML file is not available
(B) The URL refers to a CGI script and the header of the script does not indicate where the
interpreter is located
(C) The path to the interpreter of the script file is invalid
(D) The requested HTML file or CGI script has insufficient permission
Can the element <First> be replaced with <first>?
(A) No, they represent different elements altogether
61 (B) Both are same
(C) First is correct only
(D) First is only correct
What i s the correct HTML for adding a background color?
(A) <background>yellow<Background>
62 (B) <body color = "yellow">
(C) <body bg color = "yellow">
(D) <body bg ="yellow">
<DT> tag is designed to fit a single line of our web page but <DD> tag will accept a
(A) Line of text
63 (B) Full paragraph
(C) Word
(D) Request
The attribute of <form> tag
(A) Method
64 (B) Action
(C) Both (a) & (b)
(D) None of these
Which of the following attributes of text box control allow to limit the maximum character?
(A) size
65 (B) len
(C) maxlength
(D) All of these
Main container for <TR>, <TD> and <TH> is
(A) <TABLE>
66 (B) <GROUP>
(C) <DATA>
(D) All of these
XML stands for?

(A) Extensible Markup Language.


67
(B) Extensible Hypertext Markup Language.
(C) Extended Markup Language.
(D) Extend Markup Language.
What is the correct syntax of the declaration which defines the XML version?:
(A) <xml version="A.0" />
68 (B) <?xml version="A.0"?>
(C) <?xml version="A.0" />
(D) None of the above
Is it easier to process XML than HTML?
(A) Yes
69 (B) No
(C) Somtimes
(D) Cant say
Kind of Parsers are
(A) well-formed
70 (B) well-documented
(C) non-validating and validating
(D) none of the above
Comment in XML document is given by
(A) <?-- -->
71 (B) <!-- --!>
(C) <!-- -->
(D) </-- -- >
Which of the following strings are a correct XML name?
(A) _myElement
72 (B) my Element
(C) #myElement
(D) None of the above
Which of the following XML fragments are well-formed?
(A) <?xml?>
73 (B) <?xml version="A.0"?>
(C) <?xml encoding="JIS"?>
(D) <?xml encoding="JIS" version="A.0"?>
Valid XML document means (most appropriate)
(A) the document has root element
74 (B) the document contains atleast one or more root element
(C) the XML document has DTD associated with it & it complies with that DTD
(D) Each element must nest inside any enclosing element property
There is a way of describing XML data, how?
(A) XML uses a DTD to describe the data
75
(B) XML uses XSL to describe data
(C) XML uses a description node to describe data
(D) Both A and C
What does DTD stand for?
(A) Direct Type Definition
76 (B) Document Type Definition
(C) Do The Dance
(D) Dynamic Type Definition
DTD includes the specifications about the markup that can be used within the document, the
specifications consists of all EXCEPT
(A) the browser name
77
(B) the size of element name
(C) entity declarations
(D) element declarations
Which of the following XML fragments are well-formed?
(A) <myElement myAttribute="someValue"/>
78 (B) <myElement myAttribute=someValue/>
(C) <myElement myAttribute=’someValue’>
(D) <myElement myAttribute="someValue’/>
How can we make attributes have multiple values:
(A) <myElement myAttribute="value1 value2"/>
79 (B) <myElement myAttribute="value1" myAttribute="value2"/>
(C) <myElement myAttribute="value1, value2"/>
(D) attributes cannot have multiple values
The use of a DTD in XML development is:
(A) required when validating XML documents
(B) no longer necessary after the XML editor has been customized
80
(C) used to direct conversion using an XSLT processor
(D) a good guide to populating a templates to be filled in when generating an XML
document automatically
While working on a JavaScript project, in your JavaScript application, which function would
you use to send messages to users requesting for text input?
(A) Display()
81
(B) Prompt()
(C) Alert()
(D) GetInput()
What will be the output of the following JavaScript code?

function printArray(a)
{
var len = a.length, i = 0;
if (len == 0)
console.log("Empty Array");
else
82
{
do
{
console.log(a[i]);
} while (++i < len);
}
}
(A) Prints the numbers in the array in order
(B) Prints the numbers in the array in the reverse order
(C) Prints 0 to the length of the array
(D) Prints “Empty Array”
Which of the following statement is not true regarding JavaScript?
(A) JavaScript is a loosely typed language
(B) JavaScript is an object-based language
83
(C) JavaScript is event driven
(D) A JavaScript embedded in an HTML document is compiled and executed by the client
browser
<html>
<head><title>JavaScript</title></head>
<body>
<script language=”JavaScript”>
var a=80
var b=(a==80 ? “pass” :”fail”);
document.write(b)
</script>
84
</body>
</html>
What will be the output of the above script?

(A) Pass
(B) Fail
(C) Null
(D) Error at line 6
Which of the following statements is false about event handlers in JavaScript?
(A) They can be included with input tags
85 (B) They can be associated with end of file processing for a database application
(C) They can be included with the form tag
(D) They are generally used to call functions when triggered
The following statements are about three important browser objects in JavaScript.
I. window object : The highest of all objects in the client-side JavaScript object hierarchy.

II. navigator object : A collection of information about the browser. Useful in browser
sniffing.
III. document object : Provides access to the document being viewed.
86
Which of the above statements is/are true?

(A) Only (I) above


(B) Only (II) above
(C) Only (III) above
(D) All (I), (II) and (III) above
What method is used to specify a container’s layout in JSP?
(A) setLayout()
87 (B) Layout()
(C) setContainerLayout()
(D) ContainerLayout()
The following web page is loaded into a web server:
88 <html>
<head><title>JavaScript question</title></head>
<body>
<script language=”JavaScript”>
book = new Array(1,2,3,4,5,6,7,8);
document.write(book[1]);
book[10]=10;
document.write(book[10]);
</script>
</body>
</html>
Once the above web page is loaded what will its body contain?

(A) 102
(B) 101
(C) 110
(D) 210
In JSP, the classes that allow primitive types to be accessed as objects are known as
(A) Primitive classes
89 (B) Object classes
(C) Boxing classes
(D) Wrapped classes
What value does readLine() return when it has reached the end of a file in JSP?
(A) Last character in the file
90 (B) False
(C) Null
(D) EOF
Which is the handler method used to invoke when uncaught JavaScript exceptions occur?
(A) Onhalt
91 (B) Onerror
(C) Both onhalt and onerror
(D) Onsuspend
The setTimeout() belongs to which object?
(A) Element
92 (B) Window
(C) Location
(D) Event
Which type of JavaScript language is ___
(A) Object-Oriented
93 (B) Object-Based
(C)Assembly-language
(D) High-level
What will the following JavaScript code snippet work? If not, what will be the error?

function tail(o)
{
for (; o.next; o = o.next) ;
94
return o;
}
(A) No, this will throw an exception as only numerics can be used in a for loop
(B) No, this will not iterate
(C) Yes, this will work
(D) No, this will result in a runtime error with the message “Cannot use Linked List”
What will be the role of the continue keyword in the following JavaScript code snippet?

while (a != 0)
{
if (a == 1)
continue;
95 else
a++;
}
(A) The continue keyword restarts the loop
(B) The continue keyword skips the next iteration
(C) The continue keyword skips the rest of the statements in that iteration
(D) The continue keyword breaks out of the loop
The keyword or the property that you use to refer to an object through which they were
invoked is _________
(A) from
96
(B) to
(C) this
(D) object
The basic difference between JavaScript and Java is _________
(A) There is no difference
97 (B) Functions are considered as fields
(C) Variables are specific
(D) Functions are values, and there is no hard distinction between methods and fields
The meaning for Augmenting classes is that ___________
(A) objects inherit prototype properties even in a dynamic state
98 (B) objects inherit prototype properties only in a dynamic state
(C) objects inherit prototype properties in the static state
(D) object doesn’t inherit prototype properties in the static state
What will be the output of the following JavaScript code?

const obj1 =
{
a: 10,
b: 15,
c: 18
99
};
const obj2 = Object.assign({c: 7, d: 1}, obj1);
console.log(obj2.c, obj2.d);
(A) 7,1
(B) 18,1
(C) Undefined
(D) Error
What will be the output of the following JavaScript code?

const object1 = {};


100
Object.defineProperties(object1,
{
property1:
{
value: 10
}
});
console.log(object1.property1);
(A) 0
(B) 10
(C) undefined
(D) error
Which of the following is a way of embedding Client-side JavaScript code within HTML
documents?
(A) From javascript:encoding
101
(B) External file specified by the src attribute of a “script” tag
(C) By using a header tag
(D) By using body tag
When does JavaScript code appear inline within an HTML file?
(A) Between the “script” tag
102 (B) Outside the “script” tag
(C) Between or Outside the “script” tag
(D) Between the header tag
Which character in JavaScript code will be interpreted as XML markup?
(A) !
103 (B) >
(C) &
(D) .
Which method is an alternative of the property location of a window object?
(A) submit()
104 (B) locate()
(C) load()
(D) write()
Which of the following uses scripted HTTP?
(A) XML
105 (B) HTML
(C) Ajax
(D) CSS
XMLHttpRequest is a ____________
(A) Object
106 (B) Class
(C) Both Object and Class
(D) Array
Which is the appropriate code to begin a HTTP GET request?
(A) request.open(“GET”,”data”);
107 (B) request.open(GET,”data.csv”);
(C) request.open(“GET”,”data.csv”);
(D) request.open(“GET”);
What are the features of Ajax?
(A) Live data binding
108 (B) Client-side template rendering
(C) Declarative instantiation of client components
(D) All of the above
Which of the following are the features of an HTTP request?
(A) URL being requested
109 (B) Optional request body
(C)Optional set of request headers
(D) All of the mentioned
Which of these package contains classes and interfaces for networking?
(A) java.io
110 (B) java.util
(C) java.net
(D) java.network
Which of these is a protocol for breaking and sending packets to an address across a
network?
(A) TCP/IP
111
(B) DNS
(C) Socket
(D) Proxy Server
Which of these is a full form of DNS?
(A) Data Network Service
112 (B) Data Name Service
(C) Domain Network Service
(D) Domain Name Service
What will be the output of the following Java program?

import java.net.*;
class networking
{
public static void main(String[] args) throws UnknownHostException
{
InetAddress obj1 = InetAddress.getByName("niet.com");
113 InetAddress obj2 = InetAddress.getByName("niet.com");
boolean x = obj1.equals(obj2);
System.out.print(x);
}
}
(A) 0
(B) 1
(C) true
(D) false
The size of an IP address in IPv6 is _________

(A) 32 bits
114
(B) 64 bits
(C) 128 bits
(D) 265 bits
In CGI, process starts with each request and will initiate OS level process.
115 (A) True
(B) False
Which class provides system independent server side implementation?
116 (A) Socket
(B) ServerSocket
(C) Server
(D) ServerReader
What happens if ServerSocket is not able to listen on the specified port?
(A) The system exits gracefully with appropriate message
117 (B) The system will wait till port is free
(C) IOException is thrown when opening the socket
(D) PortOccupiedException is thrown
What does bind() method of ServerSocket offer?
(A) binds the serversocket to a specific address (IP Address and port)
118 (B) binds the server and client browser
(C) binds the server socket to the JVM
(D) binds the port to the JVM
Which class represents an Internet Protocol address?
(A) InetAddress
119 (B) Address
(C) IP Address
(D) TCP Address
What happens if IP Address of host cannot be determined?
(A) The system exit with no message
120 (B) UnknownHostException is thrown
(C) IOException is thrown
(D) Temporary IP Address is assigned
Which of the following is not an Enterprise Beans type?
A. Doubleton
121 B. Singleton
C. Stateful
D. Stateless
Which of the following is not true about Java beans?
A. Implements java.io.Serializable interface
122 B. Extends java.io.Serializable class
C. Provides no argument constructor
D. Provides setter and getter methods for its properties
Which of the following is correct error when loading JAR file with duplicate name?
A. java.io.NullPointerException
123 B. java.lang.ClassNotFound
C. java.lang.ClassFormatError
D. java.lang.DuplicateClassError
Java Beans are extremely secured?
124 A. True
B. False
Which of the following is not a feature of Beans?
A. Introspection
125 B. Events
C. Persistence
D. Serialization
What is the attribute of java bean to specify scope of bean to have single instance per Spring
IOC?
126 A. prototype
B. singleton
C. request
D. session
Which of the following is true about session bean?
A. This type of bean stores data of a particular user for a single session
B. This is a type of enterprise bean which is invoked by EJB container when it receives a
127
message from queue or topic
C. This type of bean represents persistent data storage
D. None of the above
Which case of a session bean obtains the UserTransaction object via the EJBContext using
the getUserTransaction() method in EJB transaction management?
A. Bean-managed transactions
128
B. Container-managed transactions
C. Both A & B
D. None of the above
Which middleware services are provided by EJB?
A. Security
129 B. Transaction Management
C. Both A & B correct
None of the above
EJB is like COM, Abbreviate the term COM?
A. Component Object Model
130 B. Component Oriented Model
C. Common Object Model
D. Common Oriented Model
The EJB specification architecture does NOT define
A. transactional components
131 B. client side security and encryption
C. distributed object components
D. server-side components
Which of the following annotation is used to specify or inject a dependency as ejb instance
into another ejb?
A. javax.ejb.Stateless
132
B. javax.ejb.Stateful
C. javax.ejb.MessageDrivenBean
D. javax.ejb.EJB
Which of the following is true?
A. Preserving of any state across method calls does not performed by Stateless session
beans
133
B. Multiple users can access Stateful session beans at the same time
C. Both are correct
D. None
Which EJB container must provide an implementation of Java Naming and Directory Interface
(JNDI) API to provide naming services for EJB clients and components?
A. Transaction support
134
B. Persistence support
C. Naming support
D. All mentioned above
Which statement about session beans is true?
135 A. In both stateless and stateful session classes, the bean provider must write the method
public void remove()
B. The method << remove >> in the component interface can be accessed only by the
remote clients
C. The bean’s handle must be provided by the client, in order to ask the EJBHome for
removing a session bean
D. None of the above
The Spring support classes facilitate building session beans
A. stateful session beans (SFSBs)
136 B. stateless session beans (SLSBs)
C. message-driven beans (MDBs)
D. All of the mentioned
Session beans don’t have
A. ejbCreate() method
137 B. ejbStore() method
C. ejbRemove() method
D. None
An entity bean's local interface MUST extend the ________ interface.
A. javax.ejb.EJBLocalObject
138 B. javax.ejb.EJBObject
C. javax.ejb.RemoteObject
D. None of the above
Which component does the Entity bean represent the persistent data stored in the database?
A. Server-side component
139 B. Client-side component
C. Server and client side component
D. None of the above
Which server-side component is required to be deployed on the server?
A. EJB
140 B. RMI
C. Both A & B
D. None of the above
Which driver is efficient and always preferable for using JDBC applications
A. Type-4 driver
141 B. Type-3 driver
C. Type-2 driver
D. Type-1 driver
In order to transfer data between a database and an application written in the Java programming
language, the JDBC API provides which of these methods?
A. Methods on the ResultSet class for retrieving SQL SELECT results as Java types.
B. Methods on the PreparedStatement class for sending Java types as SQL statement
142
parameters.
C. Methods on the CallableStatement class for retrieving SQL OUT parameters as Java
types.
D. All mentioned above
The interface ResultSet has a method, getMetaData(), that returns a/an
A. Tuple
143 B. Value
C. Object
D. Result
Which JDBC type represents a "single precision" floating point number that supports seven
144
digits of mantissa?
A. Real
B. Double
C. Float
D. Integer
Which JDBC driver Type(s) can be used in either applet or servlet code?
A. Both Type 1 and Type 2
145 B. Both Type 1 and Type 3
C. Both Type 3 and Type 4
D. Type 4 only
What are the major components of the JDBC?
A. DriverManager, Driver, Connection, Statement, and ResultSet
146 B. DriverManager, Driver, Connection, and Statement
C. DriverManager, Statement, and ResultSet
D. DriverManager, Connection, Statement, and ResultSet
Which of the following method is used to perform DML statements in JDBC?
A. executeResult()
147 B. executeQuery()
C. executeUpdate()
D. execute()
Which of the following method is static and synchronized in JDBC API?
A. getConnection()
148 B. prepareCall()
C. executeUpdate()
D. executeQuery()
Parameterized queries can be executed by?
A. ParameterizedStatement
149 B. PreparedStatement
C. CallableStatement and Parameterized Statement
D. All kinds of Statements
A good way to debug JDBC-related problems is to enable…….
A. JDBC tracing
150 B. Exception handling
C. Both a and b
D. Only b
What must be the first characters of a database URL?
A. db,
151 B. db:
C. jdbc,
D. jdbc:
Which of these obtains a Connection?
A. Connection.getConnection(url)
152 B. Driver.getConnection(url)
C. DriverManager.getConnection(url)
D. new Connection(url)
Which is responsible for getting a connection to the database?
A. Driver
153 B. Connection
C. Statement
D. ResultSet
154 What is the correct order to close database resources?
A. Connection then Statement then ResultSet
B. ResultSet then Statement then Connection
C. Statement then Connection then ResultSet
D. Statement then ResultSet then Connection
Which of the following is not a valid type of ResultSet?
A. ResultSet.TYPE_FORWARD_ONLY
155 B. ResultSet.TYPE_SCROLL_INSENSITIVE
C. ResultSet.TYPE_SCROLL_SENSITIVE
D. ResultSet.TYPE_BACKWARD_ONLY
Which JDBC driver type is the JDBC-ODBC type?
A. Type 1
156 B. Type 2
C. Type 3
D. Type 4
Which of the following is efficient than a statement due to the pre-compilation of SQL?
A. Statement
157 B. PreparedStatement
C. CallableStatement
D. None of the above.
Which JDBC driver Type(s) can be used in either applet or servlet code?
A. Both Type 1 and Type 2
158 B. Both Type 1 and Type 3
C. Both Type 3 and Type 4
D. Type 4 only
Which JDBC driver Type(s) can you use in a three-tier architecture and if the Web server and
the DBMS are running on the same machine?
A. Type 1 only
159
B. Type 2 only
C. Both Type 3 and Type 4
D. All of Type 1, Type 2, Type 3 and Type 4
Which JDBC driver Types are for use over communications networks?
A. Type 3 only
160 B. Type 4 only
C. Both Type 3 and Type 4
D. Neither Type 3 nor Type 4
What servlet processor was developed by Apache Foundation and Sun?
A. Apache Tomcat
161 B. Apache Web server
C. Sun servlet processor
D. None of the above is correct.
What is invoked via HTTP on the Web server computer when it responds to requests from a
user's Web browser?
A. A Java application
162
B. A Java applet
C. A Java servlet
D. None of the above is correct.
When service() method of servlet gets called?
A. The service() method is called when the servlet is first created.
163
B. The service() method is called whenever the servlet is invoked.
C. Both of the above.
D. None of the above.
Which of the following method can be used to get complete list of all parameters in the current
request?
A. request.getParameter()
164
B. request.getParameterValues()
C. request.getParameterNames()
D. None of the above.
Which of the following code is used to get session in servlet?
A. request.getSession()
165 B. response.getSession()
C. new Session()
D. None of the above.
How to create a cookie in servlet?
A. Use new operator.
166 B. Use request.getCookie() method
C. Use response.getCookie() method
D. None of the above
How constructor can be used for a servlet?
A. Initialization
167 B. Constructor function
C. Initialization and Constructor function
D. Setup() method
Can servlet class declare constructor with ServletConfig object as an argument?
168 A. True
B. False
What is the difference between servlets and applets?
i. Servlets execute on Server; Applets execute on browser
ii. Servlets have no GUI; Applet has GUI
iii. Servlets creates static web pages; Applets creates dynamic web pages
169 iv. Servlets can handle only a single request; Applet can handle multiple requests
A. i, ii, iii are correct
B. i, ii are correct
C. i, iii are correct
D. i, ii, iii, iv are correct
Which of the following code is used to get an attribute in a HTTP Session object in servlets?
A. session.getAttribute(String name)
170 B. session.alterAttribute(String name)
C. session.updateAttribute(String name)
D. session.setAttribute(String name)
When destroy() method of a filter is called?
A. The destroy() method is called only once at the end of the life cycle of a filter
171 B. The destroy() method is called after the filter has executed doFilter method
C. The destroy() method is called only once at the begining of the life cycle of a filter
D. The destroyer() method is called after the filter has executed
How is the dynamic interception of requests and responses to transform the information done?
A. servlet container
172 B. servlet config
C. servlet context
D. servlet filter
173 Which are the session tracking techniques?
i. URL rewriting
ii. Using session object
iii.Using response object
iv. Using hidden fields
v. Using cookies
vi. Using servlet object
A. i, ii, iii, vi
B. i, ii, iv, v
C. i, vi, iii, v
D. i, ii, iii, v
Which object of HttpSession can be used to view and manipulate information about a session?
A. session identifier
174 B. creation time
C. last accessed time
D. All mentioned above
Which type of ServletEngine is a server that includes built-in support for servlets?
A. Add-on ServletEngine
175 B. Embedded ServletEngine
C. Standalone ServletEngine
D. None of the above
What type of servlets use these methods doGet(), doPost(),doHead, doDelete(), doTrace()?
A. Genereic Servlets
176 B. HttpServlets
C. All of the above
D. None of the above
Which of these ways used to communicate from an applet to servlet?
A. RMI Communication
177 B. HTTP Communication
C. Socket Communication
D. All mentioned above
Which cookie it is valid for single session only and it is removed each time when the user
closes the browser?
A. Persistent cookie
178
B. Non-persistent cookie
C. All the above
D. None of the above
Which packages represent interfaces and classes for servlet API?
A. javax.servlet
179 B. javax.servlet.http
C. Both A & B
D. None of the above
Which class can handle any type of request so that it is protocol-independent?
A. GenericServlet
180 B. HttpServlet
C. Both A & B
D. d. None of the above
Which method in session tracking is used in a bit of information that is sent by a web server to
a browser and which can later be read back from that browser?
181
A. HttpSession
B. URL rewriting
C. Cookies
D. Hidden form fields
If a jsp is to generate a pdf page, what attribute of page directive it should use?
A. contentType
182 B. generatePdf
C. typePDF
D. contentPDF
Which of the following do not supports JSP directly?
A. Weblogic Server
183 B. WebSphere Server
C. Tomcat Server
D. Apache HTTP Server
Which of the following is true about <jsp:setProperty> action?
A. The setProperty action sets the properties of a Bean.
184 B. The Bean must have been previously defined before using setProperty action.
C. Both of the above.
D. None of the above.
What JSTL stands for?
A. JavaServer Pages Standard Tag Library
185 B. JSP Tag Library
C. Java Standard Tag Library
D. None of the above.
Which tag should be used to pass information from JSP to included JSP?
A. Using <%jsp:page> tag
186 B. Using <%jsp:param> tag
C. Using <%jsp:import> tag
D. Using <%jsp:useBean> tag
_jspService() method of HttpJspPage class should not be overridden.
187 A. True
B. False
Which one is the correct order of phases in JSP life cycle?
A. Initialization, Cleanup, Compilation, Execution
188 B. Initialization, Compilation, Cleanup, Execution
C. Compilation, Initialization, Execution, Cleanup
D. Cleanup, Compilation, Initialization, Execution
Which is not a directive?
A. include
189 B. page
C. export
D. useBean
Which is mandatory in <jsp:useBean /> tag?
A. id, class
190 B. id, type
C. type, property
D. type,id
Which of the scripting of JSP not putting content into service method of the converted servlet?
A. Declarations
191 B. Scriptlets
C. Expressions
D. None of the above
The difference between Servlets and JSP is the …………….
A. translation
192 B. compilation
C. syntax
D. Both A and B
Which of the following are the valid scopes in JSP?
A. request, page, session, application
193 B. request, page, session, global
C. response, page, session, application
D. request, page, context, application
JSP includes a mechanism for defining …………………………. or custom tags.
A. static attributes
194 B. local attributes
C. dynamic attributes
D. global attributes
Why DB connections are not written directly in JSPs?
A. Response is slow
195 B. Not a standard J2EE architecture
C. Load Balancing is not possible
D. Both B and C
How many jsp implicit objects are there and these objects are created by the web container that
are available to all the jsp pages?
A. 8
196
B. 9
C. 10
D. 7
How does Tomcat execute a JSP?
A. As a CGI script
197 B. As an independent process
C. By one of Tomcat's threads
D. None of the above is correct.
How many copies of a JSP page can be in memory at a time?
A. One
198 B. Two
C. Three
D. Unlimited
What programming language(s) or scripting language(s) does Java Server Pages (JSP)
support?
A. VBScript only
199
B. Jscript only
C. Java only
D. All of the above are supported
A JSP is transformed into a(n):
A. Java applet.
200 B. BJava servlet.
C. CEither 1 or 2 above.
D. Neither 1 nor 2 above.
Q. No. Answer Q. No. Answer Q. No. Answer Q. No. Answer Q. No. Answer
1 B 41 C 81 B 121 A 161 A
2 A 42 D 82 A 122 B 162 C
3 A 43 A 83 D 123 C 163 B
4 C 44 B 84 A 124 B 164 C
5 A 45 B 85 B 125 D 165 A
6 B 46 C 86 D 126 B 166 A
7 D 47 B 87 A 127 A 167 C
8 B 48 B 88 D 128 A 168 B
9 A 49 B 89 D 129 C 169 B
10 B 50 C 90 C 130 A 170 A
11 A 51 B 91 B 131 B 171 A
12 A 52 B 92 B 132 D 172 D
13 D 53 C 93 B 133 A 173 B
14 A 54 D 94 C 134 C 174 D
15 A 55 B 95 C 135 C 175 C
16 C 56 D 96 C 136 D 176 B
17 C 57 C 97 D 137 A 177 D
18 C 58 C 98 A 138 A 178 B
19 D 59 D 99 A 139 A 179 C
20 B 60 D 100 B 140 A 180 A
21 D 61 B 101 B 141 A 181 C
22 A 62 C 102 A 142 D 182 A
23 C 63 B 103 C 143 C 183 D
24 D 64 C 104 A 144 A 184 C
25 C 65 C 105 C 145 C 185 A
26 C 66 A 106 C 146 A 186 A
27 C 67 D 107 C 147 C 187 A
28 A 68 B 108 D 148 A 188 C
29 B 69 A 109 D 149 B 189 C
30 C 70 C 110 C 150 A 190 A
31 A 71 C 111 A 151 D 191 C
32 D 72 A 112 D 152 C 192 C
33 B 73 B 113 C 153 A 193 A
34 D 74 C 114 C 154 B 194 C
35 D 75 D 115 A 155 D 195 D
36 C 76 B 116 B 156 A 196 B
37 D 77 A 117 C 157 B 197 C
38 A 78 A 118 A 158 C 198 A
39 B 79 D 119 A 159 D 199 C
40 A 80 A 120 B 160 C 200 B

You might also like