0% found this document useful (0 votes)
36 views21 pages

Assign3 Ajp Merged

The document contains an assignment on networking concepts in Java with 20 multiple choice questions. It covers topics like network protocols (TCP, UDP), socket types, InetAddress class, and differences between TCP and UDP. The assignment is from the subject "Advanced Java Programming" for class CO5I of academic year 2023-24. Students need to submit the solved assignment by 17th October 2023.

Uploaded by

ladshruti1405
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)
36 views21 pages

Assign3 Ajp Merged

The document contains an assignment on networking concepts in Java with 20 multiple choice questions. It covers topics like network protocols (TCP, UDP), socket types, InetAddress class, and differences between TCP and UDP. The assignment is from the subject "Advanced Java Programming" for class CO5I of academic year 2023-24. Students need to submit the solved assignment by 17th October 2023.

Uploaded by

ladshruti1405
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/ 21

MGM’s POLYTECHNIC

MGM’s campus, N-6, CIDCO, Aurangabad-431003, Tel: +91-240-2482893/2484693, Fax: 2482235


Date :4 Oct 2023
Assignment No. 3
Subject: Advance Java Programming (22517) Class : CO5I A.Y. 2022-23
Name of Student : Roll No.:

ActionEvent & AdjustmentEvent Class


1. Which of these events is generated when a button is pressed?
a) ActionEvent b) KeyEvent c) WindowEvent d) AdjustmentEvent

2. What is an event in delegation event model used by Java programming language?


a) An event is an object that describes a state change in a source.
b) An event is an object that describes a state change in processing.
c) An event is an object that describes any change by the user and system.
d) An event is a class used for defining object, to create events.

3. Which of these methods can be used to obtain the command name for invoking
ActionEvent object?
a) getCommand() b) getActionCommand() c) getActionEvent()
d) getActionEventCommand()

4. Which of these are integer constants defined in ActionEvent class?


a) ALT_MASK b) CTRL_MASK c) SHIFT_MASK d) All of the mentioned

5. Which of these methods can be used to know which key is pressed?


a) getKey() b) getModifier() c) getActionKey() d) getActionEvent()

6. Which of these events is generated by scroll bar?


a) ActionEvent b) KeyEvent c) WindowEvent d) AdjustmentEvent

7. Which of these methods can be used to determine the type of adjustment event?
a) getType() b) getEventType() c) getAdjustmentType() d) getEventObjectType()

8. Which of these methods can be used to know the degree of adjustment made by the
user?
a) getValue() b) getAdjustmentType() c) getAdjustmentValue()
d) getAdjustmentAmount()

9. Which of these events will be notified if scroll bar is manipulated?


a) ActionEvent b) ComponentEvent c) AdjustmentEvent d) WindowEvent
10. Which of these constant value will change when the button at the end of scroll bar
was clicked to increase its value?
a) BLOCK_DECREMENT b) BLOCK_INCREMENT c) UNIT_DECREMENT
d) UNIT_INCREMENT

ComponentEvent, ContainerEvent & FocusEvent Class


1.Which of these events is generated when the size of an event is changed?
a) ComponentEvent b) ContainerEvent c) FocusEvent d) InputEvent

2. Which of these events is generated when the component is added or removed?


a) ComponentEvent b) ContainerEvent c) FocusEvent d) InputEvent

3. Which of these methods can be used to obtain the reference to the container that
generated a ContainerEvent?
a) getContainer() b) getContainerCommand() c) getActionEvent()
d) getContainerEvent()

4. Which of these methods can be used to get reference to a component that was
removed from a container?
a) getComponent() b) getchild() c) getContainerComponent()
d) getComponentChild()

5. Which of these are integer constants of ComponentEvent class?


a) COMPONENT_HIDDEN b) COMPONENT_MOVED
c) COMPONENT_RESIZE d) All of the mentioned

6. Which of these events is generated when computer gains or losses input focus?
a) ComponentEvent b) ContainerEvent c) FocusEvent d) InputEvent

7. FocusEvent is subclass of which of these classes?


a) ComponentEvent b) ContainerEvent c) ItemEvent d) InputEvent

8. Which of these methods can be used to know the type of focus change?
a) typeFocus() b) typeEventFocus() c) isTemporary() d) isPermanent()

9. Which of these is superclass of ContainerEvent class?


a) WindowEvent b) ComponentEvent c) ItemEvent d) InputEvent

MouseEvent, TextEvent & WindowEvent Class


1. Which of these events is generated when the window is closed?
a) TextEvent b) MouseEvent c) FocusEvent d) WindowEvent
2. Which of these events is generated when the component is added or removed?
a) ComponentEvent b) ContainerEvent c) FocusEvent d) InputEvent

3. Which of these methods can be used to obtain the coordinates of a mouse?


a) getPoint() b) getCoordinates() c) getMouseXY() d) getMouseCordinates()

4. Which of these methods can be used to change location of an event?


a) ChangePoint() b) TranslatePoint() c) ChangeCordinates()
d) TranslateCordinates()

5. Which of these are integer constants of TextEvent class?


a) TEXT_CHANGED b) TEXT_FORMAT_CHANGED c) TEXT_VALUE_CHANGED
d) TEXT_SIZE_CHANGED

6. Which of these methods is used to obtain the object that generated a WindowEvent?
a) getMethod() b) getWindow() c) getWindowEvent() d) getWindowObject()

7. MouseEvent is subclass of which of these classes?


a) ComponentEvent b) ContainerEvent c) ItemEvent d) InputEvent

8. Which of these methods is used to get x coordinate of the mouse?


a) getX() b) getXCoordinate() c) getCoordinateX() d) getPointX()

9. Which of these are constants defined in WindowEvent class?


a) WINDOW_ACTIVATED b) WINDOW_CLOSED c) WINDOW_DEICONIFIED
d) All of the mentioned

10. Which of these is superclass of WindowEvent class?


a) WindowEvent b) ComponentEvent c) ItemEvent d) InputEvent

Event Listeners Interfaces


1. Which of these packages contains all the event handling interfaces?
a) java.lang b) java.awt c) java.awt.event d) java.event

2. Which of these interfaces handles the event when a component is added to a


container?
a) ComponentListener b) ContainerListener c) FocusListener d) InputListener

3. Which of these interfaces define a method actionPerformed()?


a) ComponentListener b) ContainerListener c) ActionListener d) InputListener

4. Which of these interfaces define four methods?


a) ComponentListener b) ContainerListener c) ActionListener d) InputListener

5. Which of these interfaces define a method itemStateChanged()?


a) ComponentListener b) ContainerListener c) ActionListener d) ItemListener
6. Which of these methods will respond when you click any button by mouse?
a) mouseClicked() b) mouseEntered() c) mousePressed() d) All of the mentioned

7. Which of these methods will be invoked if a character is entered?


a) keyPressed() b) keyReleased() c) keyTyped() d) keyEntered()

8. Which of these methods is defined in MouseMotionAdapter class?


a) mouseDragged() b) mousePressed() c) mouseReleased() d) mouseClicked()

9. Which of these is superclass of all Adapter classes?


a) Applet b) ComponentEvent c) Event d) InputEvent

Note: Submit this assignment up to 7 Oct 2023


Subject Teacher
Deshmukh R.R.
MGM’s POLYTECHNIC
MGM’s campus, N-6, CIDCO, Aurangabad-431003, Tel: +91-240-2482893/2484693, Fax: 2482235
Date :17 October 2023
Assignment No. 4

Subject: Advance Java Programming (22517) Class : CO5I A.Y. 2023-24


Name of Student :Roll No.:

Q. 1 A set of rules that governs data communication:


(A)Protocols (b) Standards (c) RFCs (d) Functions

Q. 2 Which of this class is used to create servers that listen for either local or remote client
programs?
(a) HttpServer (b) MimeHeader (c) HttpResponse (d) ServerSockets

Q. 3 A _______is a program providing services to the _____ program.


(A) Server, Client (b) Client, Server (d) Host, Client (c) Server, Server

Q. 4 server can process multiple requests at a time.


(a) An iterative (B) A concurrent (c) A concurrent or an iterative (d) None of these

Q.5 Network programming needs information to be in the form of ---------_byte order.


(a) host (b) network (c) client (d) server

Q. 6 Communication using TCP protodcol is ------


(a) connectionless, iterative (b) connectionless, concurrent (c) connection-oriented,
iterative
(d) connection-oriented, concurrent

Q. 7 Communication using UDP protocol is -------and---------.


(a) connectionless, iterative (b) connectionless, concurrent (c) connection-oriented,
iterative
(d) connection-oriented, concurrent

Q. 8 -------- is a server that is mediator between real web server and client application.
(a) Host (b) H'ITP (c) Proxy (d) Web

Q. 9 SOCK_STREAM sockets are used by --------- processes.


(a) TCP (b) UDP (c) SCTP (d) FTP

Q. 10 SOCK_DGRAM sockets are used by ---------- processes.


(a) TCP (b) UDP (c) SCTP (d) FTP

Q. 11 Which package contains classes and interfaces for networking?
(a) java.io (b) java.util (c) java.net (d) java.network

Q. 12 Port number of Telnet is __ .


(a) 21 (b) 23 (d) 79 (c) 25

Q. 13 java.net package consist of interface __ .


(a) ContentHandler Factory. (b) SocketImplfactory (c) SocketOption (d) All of above

Q.14 __ is a protocol for breaking and sending packets to an address across a network?
(a) TCIP b) IP (c) Socket

Q.15 Full form of DNS is


(a) Data Network Service (b) Data Name Service (c) Domain Network Service
(d) Domain Name System

Q. 16 TCP is -------- oriented protocol.


(a) stream (b) message (c) block (d) segment

Q.17 What is the output of this program?


importjava.net.*;
class networking {
publicstaticvoid main(String[]args)throwsUnknownHostException{
InetAddress obj1 =InetAddress.getByName("sanfoundary.com");
InetAddress obj2 =InetAddress.getByName("sanfoundary.com");
boolean x = obj1.equals(obj2);
System.out.print(x);
}
}
a) 0 b) 1 c) true d) false

Q.18 What is the output of this program?


importjava.net.*;
class networking {
publicstaticvoid main(String[]args)throwsUnknownHostException{
InetAddress obj1 =InetAddress.getByName("cisco.com");
InetAddress obj2 =InetAddress.getByName("sanfoundary.com");
boolean x = obj1.equals(obj2);
System.out.print(x);
}
}

a) 0 b) 1 c) true d) false

Q.19. What is the output of this program?


importjava.net.*;
class networking {
publicstaticvoid main(String[]args)throwsUnknownHostException{
InetAddress obj1 =InetAddress.getByName("cisco.com");
System.out.print(obj1.getHostName());
}
}

a) cisco b) cisco.com c) www.cisco.com d) None of the mentioned

Q.20. What is the output of this program?


importjava.net.*;
class networking {
publicstaticvoid main(String[]args)throwsException{
URLobj=newURL("http://www.sanfoundry.com/javamcq");
URLConnection obj1 =obj.openConnection();
System.out.print(obj1.getContentType());
}
}
Note: Host URL is written in html and simple text.
a) html b) text c) html/text d) text/html

Q.21. What is the output of this program?


importjava.net.*;
class networking {
publicstaticvoid main(String[]args)throwsMalformedURLException{
URLobj=newURL("http://www.sanfoundry.com/javamcq");
System.out.print(obj.toExternalForm());
}
}
a) sanfoundry b) sanfoundry.com
c) www.sanfoundry.com d) http://www.sanfoundry.com/javamcq

Q.22.What is the output of this program?


1. importjava.net.*;
2. class networking {
3. publicstaticvoid main(String[]args)throwsMalformedURLException{
4. URLobj=newURL("http://www.sanfoundry.com/javamcq");
5. System.out.print(obj.getProtocol());
6. }
7. }
a) http b) https c) www d) com

Q.23. What is the output of this program?


1. importjava.net.*;
2. class networking {
3. publicstaticvoid main(String[]args)throwsMalformedURLException{
4. URLobj=newURL("http://www.sanfoundry.com/javamcq");
5. System.out.print(obj.getPort());
6. }
7. }
a) 1 b) 0 c) -1 d) garbage value

Q. 24 Exception is thrown by URL class's constructors is __ .


(a) URLNotFound (b) URLSourceNotFound (c) MalformedURLException (d)
URLException

Q. 25 Which method is used to know the full URL of an URL object?


(a) fullHostURL() (b) getHostURL() (c) ExternalForm() (d) toExternalForm()

Q. 26 Which class is used to access actual bits or content information of a URL ?


(a) URL (b) URLConnection (c) URLDecoder (d) All of the mentioned

Q. 27 __ thrown to indicate that the IP address of a host could not be determined.


(a) UnknownHostException (b) IOException (c) HostNotFoundException (d) None of these

Q. 28 What are the types offactory pattern ?


(a) Factory Method (b) Abstract Method (c) All of-the above (d) None ofthe above

Q. 29 Which class have only one instance?


(a) Adaptor Class (b) Singleton Class (c) Factory class (d) Proxy Class

Q. 30 A __ variable is shared by all instances of the class. It exists even before an object is
created.
(a) abstract (b) instance (c) interface (d) static

Q. 31 __ is wrapper around everything associated with a reply from an http server?


(a) HTTP (b) HttpResponse (c) Httpserver (d) httpserver

Q. 32 __ is a bundle of information passed between machines.


(a) Protocol (b) Cache (c) Datagrams (d) Segment

Q. 33 __ class is necessary to implement datagrams.


(a) DatagramPacket (b) DatagramSocket (c) Datagram d) Both (a) and (b)

Q. 34 __ method of DatagramPacket is used to find the port number.


(a) portO (b) getPortO (c) GetPortO (d) findPortO

Q. 35 Which of these transfer protocol must be used so that URL can be accessed by
URLConnectionclass object?
(a) http (b) https (c) URL (d) None of the mentioned

Q.36--------------- method is used to know when URL is last modified.


(a) LastModifiedO (b) getLastModifiedO (c) getlastModifiedO (d) GetLastModifiedO

Q. 37 __ method is used to know the type of content used in theURL.


(a) ContenttypeO (b) contentTypeO (c) getContentTypeO (d) GetContentTypeO

Q. 38 Which package is used for handling security related issues in a program ?


(a) java.security (b) java.lang.security (c) java.awt.image (d) java.io.security

Q. 39 Class which allows us to get real time data about private and protected member of a
class is __ .(a) java.io.security (b) java.GetInformation (c) ReflectPermission (d)
MembersPermission

Q. 40 The packages contain classes and interfaces used for input and output operations of a
program is __ .
(a) java.util (b) java.lang (c) java.io (d) java.file.io

Q. 41 __ class is not a member class of java.io package.


(a) File (b) StringReader (c) Writer (d) String

Q. 42 To return the currently installed policy object __ method is used.


(a) public Policy getPolicyO
(b) public static Policy GetPolicyO (c) public Policy getPolicyO
(d) public static Policy getPolicyO

Q.43A _____ is responsible for determining whether code


executing in the Java runtime environment has permission to perform a security-sensitive
operation.
(a) security object (b) security class (c) policy object (d) policy method

Q.44 Permission class is a part of _____ package.


(a) java.security (b) java.lang.Object (c) java.permission.security (d)
java.security.Permission

Q. 45 Which of following are sub classes of permission class?


(a) AlIPermission (b) FilePermission (c) ServicePermission (d) All of-the above

Q.46 What is the output of this program?


1. importjava.net.*;
2. class networking {
3. publicstaticvoid main(String[]args)throwsMalformedURLException{
4. URLobj=newURL("http://www.sanfoundry.com/javamcq");
5. System.out.print(obj.getHost());
6. }
7. }

a)sanfoundry b) sanfoundry.com
c) www.sanfoundry.com d) http://www.sanfoundry.com/javamcq

Q.47 What is the output of this program?


1. importjava.net.*;
2. class networking {
3. publicstaticvoid main(String[]args)throwsMalformedURLException{
4. URLobj=newURL("http://www.sanfoundry.com/javamcq");
5. System.out.print(obj.toExternalForm());
6. }
7. }
a) sanfoundry b) sanfoundry.com c) www.sanfoundry.com
• D) http://www.sanfoundry.com/javamcq

48) Show some networking terminologies given below?


A) IP Address B) Protocol C) MAC Address D) All mentioned above

49) TCP,FTP,Telnet,SMTP,POP etc. are examples of ?


A) Socket B) IP Address C) Protocol D) MAC Address

50) Which classes are used for connection-oriented socket programming?


A) Socket B) ServerSocket C) Both A & B D) None of the above
Note: Submit this assignment up to 21 Oct 2023
Subject Teacher
Deshmukh R.R.
MGM’s POLYTECHNIC
MGM’s campus, N-6, CIDCO, Aurangabad-431003, Tel: +91-240-2482893/2484693, Fax:
2482235

Date :25 October 2023


Assignment No. 5

Subject: Advance Java Programming (22517) Class : CO5I A.Y. 2023-24


Name of Student : Roll No.:

Q.1 The JDBC-ODBC bridge is

[A] Multithreaded
[B] Singlethreaded
[C] Both of the above
[D] none of the above

Q.2 . Which statements about JDBC are true?

[A] JDBC is an API to connect to relational-, object- and XML data sources
[B] JDBC stands for Java DataBase Connectivity
[C] JDBC is an API to access relational databases,
[D] JDBC is an API to bridge the object-relational mismatch between OO programs and
relational databases

Q. 3 . Which packages contain the JDBC classes?


[A] java.jdbc and javax.jdbc
[B] java.jdbc and java.jdbc.sql
[C] java.sql and javax.sql
[D] java.rdb and javax.rdb
Q.4 Which type of driver provides JDBC access via one or more ODBC drivers?
[A] Type 1 driver
[B] Type 2 driver
[C] Type 3 driver
[D] Type 4 driver
Q5. Which type of driver converts JDBC calls into the network protocol used by the
database management system directly
[A] Type 1 driver
[B] Type 2 driver
[C] Type 3 driver
[D] Type 4 driver

Q. 6 What MySQL property is used to create a surrogate key in MySQL?


[A] UNIQUE
[B] SEQUENCE
[C] AUTO_INCREMENT
[D] None of the above -- Surrogate keys are not implemented in MySQL.

Q. 7. is an open source DBMS product that runs on UNIX, Linux and Windows.
[A] MySQL
[B] JSP/SQL
[C] JDBC/SQL
[D] Sun ACCESS

Q. 8 . Which JDBC driver Type(s) can be used in either applet or servlet code?.
[A] Both Type 1 and Type 2
[B] Both Type 1 and Type 3
[C] Both Type 3 and Type 4
[D] Type 4 only
Q.9. Where is metadata stored in MySQL?
[A] In the MySQL database metadata
[B] n the MySQL database metasql
[C] In the MySQL database mysql
[D] None of the above is correct.
Q. 10 . Which of the following methods are needed for loading a database driver in
JDBC?
[A] registerDriver() method
[B] Class.forName()
[C] Both A and B
[D] getConnection()
Q. 11 Which of the following statements is false as far as different type of statements is
concern in JDBC?.
[A] Regular Statement
[B] Prepared Statement
[C] Callable Statement
[D] Interim Statement
Q.12. Which of the following allows non repeatable read in JDBC Connection?
[A] TRANSACTION_READ_UNCOMMITTED
[B] TRANSACTION_READ_COMMITTED
[C] TRANSACTION_SERIALIZABLE
[D] TRANSACTION_REPEATABLE_READ

Q13. The JDBC-ODBC Bridge supports multiple concurrent open statements per
connection?
[A] True
[B] False
Q.14 Which type of Statement can execute parameterized queries?
[A] PreparedStatement
[B] ParameterizedStatement
[C] ParameterizedStatement and CallableStatement
[D] All kinds of Statements
Q15. How can you retrieve information from a ResultSet?
[A] By invoking the method get(..., String type) on the ResultSet, where type is the
database type
[B] By invoking the method get(..., Type type) on the ResultSet, where Type is an object
which represents a database type
[C] By invoking the method getValue(...), and cast the result to the desired Java type.
[D] By invoking the special getter methods on the ResultSet: getString(...),
getBoolean (...), getClob(...)
Q16. How can you execute a stored procedure in the database?
[A] Call method execute() on a CallableStatement object
[B] Call method executeProcedure() on a Statement object
[C] Call method execute() on a StoredProcedure object
[D] Call method run() on a ProcedureCommand object

Q17. executeQuery() method returns


A. Single row
B. ResultSet object
C. Single Column
D. Database Table

Q18.PreparedStatement interface extends interface


A. Connection
B. Statement
C. ResultSet
D. Driver

Q19.executeUpdate() method returns


A. Single row
B. ResultSet object
C. Integer
D. Single Column

Q20. For execution of DELETE SQL query in JDBC, method must be used.
A. executeQuery()
B. executeDeleteQuery()
C. executeUpdate()
D. executeDelete()

Q21. Prepared Statement object in JDBC used to execute queries.


A. Executable
B. Simple
C. High level
D. Parameterized

Q22 is a full form of SQL


A. Standard query language
B. Sequential query language
C. Structured query language
D. Server side query language
Q23.How many JDBC driver types does Oracle define?
[A] one
[B] two
[C] three
[D] four
Q24. Which of the following is not the standard isolation levels defined by JDBC?

A - TRANSACTION_NONE

B - TRANSACTION_READ_COMMITTED

C - TRANSACTION_READ_UNCOMMITTED
D - TRANSACTION_WRITE_UNCOMMITTED
Q25 Which JDBC type represents a "single precision" floating point number that
supports seven digits of mantissa?
A. REAL
B. DOUBLE
C. FLOAT
D. INTEGER
Q26.Abbreviate the term UDA?
A. Unified Data Access
B. Universal Data Access
C. Universal Digital Access
D. Uniform Data Access

Q27.Which method Drops all changes made since the previous commit/rollback?
A. public void rollback()
B. public void commit()
C. public void close()
D. public Statement createStatement()
Q26 .Which methods returns a stream that simply provides the raw bytes from the
database without any conversion?
A. getCharacterStream
B. getBinaryStream
C. getAsciiStream
D. getUnicodeStream
Q27 Which of the following contains both date and time?
A java.io.date
B java.sql.date
C
java.util.date
D java.util.dateTime
Q28 .Which of the following is used to call stored procedure?
A Statement
B PreparedStatement
C CallableStatment
D CalledStatement
Q29 Which of the following is used to limit the number of rows
returned? A setMaxRows(int i)
B setMinRows(int i)
C getMaxrows(int
i) D
getMinRows(int i)
Q30 .Which of the following is method of JDBC batch process
A setBatch()
B deleteBatch()
Cr emoveBatch()
D addBatch()
Q31. Which method is used to establish the connection with the specified url in a Driver
Manager class?
A. public static void registerDriver(Driver driver)
B. public static void deregisterDriver(Driver driver)
C. public static Connection getConnection(String url)
D. public static Connection getConnection(String url,String userName,String password)

Q32. Which JDBC type represents a 64-bit signed integer value between -
9223372036854775808 and 9223372036854775807?
A. SMALLINT
B. BIGINT
C. TINYINT
D. INTEGER
Q33 .Which model does a Java applet or application talks directly to the data source?
A. Two-tier models
B. Three-tier models
C. Both A & B
D. None of the above
Q34. What is the reason that a java program cannot directly communicate with an
ODBC driver?
A. ODBC written in C# language
B. ODBC written in C language
C. ODBC written in C++ language
D. None of the above
Q35. In the following JDBC drivers which is known as fully java driver?
A. Native-API driver
B. Network Protocol driver
C. Thin driver
D. Both B & C

Subject teacher
nd
Last date of submission is 2 Nov 23
MGM’s POLYTECHNIC
MGM’s campus, N-6, CIDCO, Aurangabad-431003, Tel: +91-240-2482893/2484693, Fax: 2482235
Date :25 October 2023
Assignment No. 5

Subject: Advance Java Programming (22517) Class : CO5I A.Y. 2023-24


Name of Student : Roll No.:

Q 1 - Which of the following is the correct order of servlet life cycle phase methods?
A - init(), service(), destroy()
B - initialize(), service(), destroy()
C - init(), execute(), destroy()
D - init(), service(), delete()

Q 2 - Which of the following method can be used to get the value of form parameter?
A - request.getParameter()
B - request.getParameterValues()
C - request.getParameterNames()
D - None of the above.

Q 3 - Which of the following code is used to get a particular attribute in servlet?


A- request.getAttribute(name)
B- B - response.getAttribute(name)
C- C - new Attribute(name)
D - None of the above.

Q 4 - Which of the following code retrieves name and version of the protocol?
A - Header.getProtocol()
B - response.getProtocol()
C - request.getProtocol()
D - None of the above.

Q 5 - Which of the following code indicates whether the response has been committed?
A - response.isCommitted()
B - request.isCommitted()
C - Header.isCommitted()
D - None of the above.

Q 6 - Which of the following code can be used to clear any data that exists in the buffer as well as
the status code and headers?
A - request.reset()
B - response.reset()
C - response.resetBuffer()
D - None of the above.

Q 7 - Which of the following is true about filters?


A - Servlet Filters are Java classes that can be used to intercept requests from a client before they
access a resource at back end.
B - Servlet Filters are Java classes that can be used to manipulate responses from server before
they are sent back to the client.
C - Both of the above.
D - None of the above.
Q 8 - How to create a cookie in servlet?
A - Use new operator.
B - Use request.getCookie() method C -
Use response.getCookie() method D -
None of the above

Q 9 - Which of the following code is used to get session id of a HTTP Session object in
servlets?
A - session.getSessionId()
B - session.getId()
C - session.getActiveId()
D - None of the above.

Q 10 - Which of the following code is used to get language name in servlets?


A - response.getDisplayLanguage()
B - Locale.getDisplayLanguage()
C - request.getDisplayLanguage()
D - None of the above.

Q 11 - Which of the following package contains servlet classes?


A - javax.servlet
B - javax.servlet.http
C - Both of the above.
D - None of the above.

Q 12 - Which of the following method can be used to get complete list of all parameters in the
current request?
A - request.getParameter()
B -request.getParameterValues() C -
request.getParameterNames()
D - None of the above.

Q 13 - Which of the following code is used to get session in servlet?


A - request.getSession()
B - response.getSession()
C - new Session()
D - None of the above.

Q14 - Which of the following code retrieves name and version of the protocol?
A - Header.getProtocol()
B - response.getProtocol()
C - request.getProtocol()
D - None of the above.

Q 15 - Which of the following code encodes the specified URL for use in the sendRedirect method?
A - response.encodeRedirectURL(url)
B - request.encodeRedirectURL(url)
C - Header.encodeRedirectURL(url)
D - None of the above.

Q16 - Which of the following code can be used to clear the content of the underlying buffer in the
response without clearing headers or status code.

A - request.reset()
B - response.reset()
C - response.resetBuffer()
D - None of the above.

Q17 - Which of the following code can be used to set the locale of the response?
A - request.setLocale(locale)
B - response.setLocale(locale)
C - header.setLocale(locale)
D - None of the above.

Q 18 - Which of the following is true about javax.servlet.error.status_code?

A - This attribute gives exact error message which can be stored and analysed after storing in a
java.lang.String data type.
B - This attribute gives information about exception type which can be stored and analysed after
storing in a java.lang.Class data type.
C - This attribute gives status code which can be stored and analysed after storing in a
java.lang.Integer data type.
D - This attribute gives information about URL calling the servlet and it can be stored and
analysed after storing in a java.lang.String data type.

Q 19 - Which of the following code sends a cookie in servlet?


A - response.addCookie(cookie);
B - response.sendCookie(cookie);
C - response.createCookie(cookie);
D - None of the above

Q 20 - Which of the following code is used to get country/region name in servlets?


A - request.getDisplayCountry()
B - Locale.getDisplayCountry()
C - response.getDisplayCountry()
D - None of the above.

Q 21 - Which of the following is true about servlets?


A - Servlets execute within the address space of a Web server.
B - Servlets are platform-independent because they are written in Java.
C - The full functionality of the Java class libraries is available to a servlet.
D - All of the above.

Q22 - Which of the following method can be used to get the multiple values of a parameter
like checkbox data?
A - request.getParameter()
B - request.getParameterValues()
C - request.getParameterNames()
D - None of the above.

Q 23 - Which of the following code is used to get names of the attributes in servlet?
A - response.getAttributeNames()
B - request.getAttributeNames()
C - Header.getAttributeNames()
D - None of the above.

Q 24 - Which of the following code retrieves any extra path information associated with the URL
the client sent?
A - Header.getPathInfo()
B - response.getPathInfo()
C - request.getPathInfo()
D - None of the above.

Q 25 - Which of the following code encodes the specified URL for use in the sendRedirect method?
A - response.encodeRedirectURL(url)
B - request.encodeRedirectURL(url)
C - Header.encodeRedirectURL(url)
D - None of the above.

Q 26 - Which of the following code can be used to add a header with the given name and integer
value?
A - request.addHeader(name,value)
B - response.addIntHeader(name,value)
C - Header.addDateHeader(name,value)
D - None of the above.

Q27 - Which of the following code can be used to set the character encoding for the body of
the response?
A - response.setCharacterEncoding(charset)
B - request.setCharacterEncoding(charset)
C - header.setCharacterEncoding(charset)
D - None of the above.

Q 28 - When doFilter() method of servlet gets called?


A - The doFilter() method is called when the filter is first created.
B - The doFilter() method is called whenever the servlet being filtered is invoked.
C - Both of the above.
D - None of the above.

Q 29 - Which of the following way can be used to keep track of previous client request?
A - Using cookies.
B - Using hidden form fields.
C - Using URL rewriting.
D - All of the above.

Q 30 - Which of the following code is used to get country/region name in servlets?


A - request.getDisplayCountry()
B - Locale.getDisplayCountry()
C - response.getDisplayCountry()
D - None of the above.

Q 31 - Which of the following is true about servlets?


A - Servlets execute within the address space of a Web server.
B - Servlets are platform-independent because they are written in Java.
C - The full functionality of the Java class libraries is available to a servlet.
D - All of the above.

Q 32 - Which of the following code is used to set content type of a page to be serviced using
servlet?
A - response.setContentType()
B - request.setContentType()
C - writer.setContentType()
D - None of the above.

Q 33 - Which of the following code is used to get session in servlet?


A - request.getSession()
B - response.getSession()
C - new Session()
D - None of the above.

Q 34 - Which of the following code retrieves the character encoding used in the body of this
request?
A - new CharacterEncoding()
B - response.getCharacterEncoding()
C - request.getCharacterEncoding()
D - None of the above.

Q 35 - Which of the following code retrieves session ID specified by the client?


A - request.getRequestedSessionId()
B - response.getRequestedSessionId()
C - Header.getRequestedSessionId()
D - None of the above.
Q 36 - Which of the following code can be used to clear any data that exists in the buffer as well
as the status code and headers?
A - request.reset()
B - response.reset()
C - response.resetBuffer()
D - None of the above.

Subject teacher

Note: Submission of this assignment is 2-11-2023

You might also like