Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
60 views

Java Mock Test Set 3

This document contains questions and answers related to Java programming concepts. It covers topics like GUI components, events, databases, JDBC, servlets, JSP and more. There are a total of 33 questions in this document.

Uploaded by

Mayur Mahajan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Java Mock Test Set 3

This document contains questions and answers related to Java programming concepts. It covers topics like GUI components, events, databases, JDBC, servlets, JSP and more. There are a total of 33 questions in this document.

Uploaded by

Mayur Mahajan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

UNIT

1 1. Which of the following method is used to set a TextComponent to read-only mode?


a. Editable( ) b. nonEditable( )
c. setEchoChar( ) d. setEditable( )

1 2. _________ generates action events when an item is double-clicked.


a. List b. Checkbox
c. MenuItem d. TextField

3 3. Which of the following method is used to determine the type of adjustment event?
a. getType( ) b. getEventType( )
c. getAdjustmentType( ) d. getEventObjectType( )

3 4. TextField generates ____________ event.


a. ActionEvent,ItemEvent b. ActionEvent, TextEvent
c. ScrollEvent,TextEvent d. ActionEvent, ScrollEvent

4 5. Connection oriented communication is possible using ____________ classes of Java.


a. Socket and ServerSocket b. DatagramSocket and
DatagramPacket
c. Both of these d. None of these

4 6. A server socket can connect to ________ clients.


a. 1 b. 2
c. 10 d. multiple

4 7. Resolver in DNS system maps __________.


a. Domain name to IP address b. IP address to domain name
c. Domain name to MAC address d. MAC address to IP address

5 8. The __________ package contains classes that help in connecting to a database, sending
SQL statements to the database and process the query request.
a. connection.sql b. db.sql
c. pkg.sql d. java.sql

5 9. Which of the following is not a type of JDBC driver?


a. 100% pure Java Driver b. JDBC – net pure Java Driver
c. JDBC – Native API driver d. JDBC – Native pure Java Driver

5 10. In JDBC ______________ imports all Java classes that are concern with Database
connectivity.
a. javax.sql b. java.mysql
c. java.sql d. com.sql

2 11. What is the use of : Container getContentPane( )


a. Returns Container for a JDialog. b. Returns a ContentPane for Menu
c. Returns a ContentPane for Applet d. None of the above

5 12. Database programming using Java throws which of the following exception?
a. SQLException b. ClassNotFoundException

1|Page
c. None of these d. Both of these

6 13. JSP embeds __________ in ___________.


a. Servlet, HTML b. HTML, Java
c. HTML, Servlet d. Java, HTML

6 14. Which of the following is the default HttpRequest method?


a. doGet( ) b. doPost( )
c. doTrace( ) d. doPut( )

6 15. Which are true about tag libraries in web application?


a. packaged in the /WEB-INF directory or sub- b. If a tag is implemented as a tag file
directory of the WAR file and packaged in /WEB-INF/tags/ or a
sub-directory, a TLD will be generated
automatically by the web container,
though, you can provide one if you
wish
c. packaged in the /META-INF/ directory or sub- d. All of the above.
directory of a tag library packaged in a jar.

6 16. Name the http method used to send resources to the server.
a. FTP method b. PUT method
c. WRITE method d. COPY method

4 17. If a program consists of three classes, then after compilation how many class files will be
created by the compiler?
a. one b. three
c. uncountable d. zero

2 18. Which of the following method is not applicable for Button in swing.
a. setDiableIcon( ) b. setPressedIcon( )
c. setSelectedIcon( ) d. setRollOverIcon( )

1 19. Which of the following does not have its default layout as BorderLayout.
a. Frame b. Dialog
c. JApplet d. All of Above

1 20. Which of the following statement about GUI component is wrong?


a. swing exists since the version 1.2 of the JDK b. AWT stands for Abstract Window
Toolkit
c. You cannot place AWT component on swing d. The AWT classes are deprecated.
container.

3 21. void keyTyped(KeyEvent ke) called when a key on the keyboard is ____________.
a. pressed and then released. b. pressed
c. released d. none of the above

4 22. Which of the following is not a method of Security class?


a. socketPermission( ) b. filePermission( )

2|Page
c. dataPermission( ) d. None of above

4 23. TCP does not supports Multicasting and Broadcasting because ______________.
a. It supports full duplex communication. b. It provides error control.
c. It provides flow control d. It is connection oriented protocol

5 24. In the below statement, which type of query can be used with executeUpdate( ) method.
statement.executeUpdate(query here)
a. Insert, Update, Delete b. Insert, Select, Delete
c. Only Select d. Any Query

5 25. What is purpose of next( ) method?


a. to retain the next element in a series. b. to retain next table.
c. to retain next record in a series. d. None of the above

6 26. Identify the proper syntax of doGet( ).


a. void doGet(HttpResponse res,HttpRequest req) b. void doGet(HttpRequest
throws IOException, ServletException req,HttpResponse res) throws
IOException, ServletException
c. void doGet(HttpResponse res) throws IOException, d. void doGet(HttpRequest req)
ServletException throws IOException, ServletException

1 27. Which of the following package is used for Graphical User Interface?
a. java.applet b. java.awt
c. java.awt.image d. java.io

6 28. Given an HttpServletRequest request and HttpServletResponse response instances. Which


sets a cookie “username” with the value “joe” in a servlet?
a. request.addCookie(new Cookie(“username” , b. response.addCookie(new
“joe)); Cookie(“username” , “joe”))
c. request.addCookie(“username” , “joe); d. request.addCookie(“username” ,
“joe);

6 29. Which JSP tag is used to transfer for processing another JSP page?
a. <jsp:include> b. <jsp:forward>
c. <jsp:useBean> d. <jsp:use:include>

3 30. Which event is generated when the position of scrollbar is changed?


a. KeyEvent b. MouseEvent
c. ItemEvent d. AdjustmentEvent

3 31. The signature for the registration method for a ActionEvent should be _______.
a. public void addActionListener(ActionEvent L) b. public void setAction(ActionListener
L)
c. public void setActionListener(ActionListener L) d. public void
addActionListener(ActionListener L)

2 32. Which of the following method is used to retrieve icon of JButton?


a. Icon getIcon( ) b. ImageIcon getImageIcon( )
c. ImageIcon getIcon( ) d. ImageIcon GetImageIcon( )

3|Page
6 33. An application wants to invalidate the session both programmatically and declaratively.
Select the best match to do this.
a. httpRequest.getSession( ).end( ) b.
<session-config> httpRequest.getSession( ).invalidate(
<session-timeout-interval>time_in_minutes )
</session-timeout-interval> <session-config>
</session-config> <session-timeout>time_in_minutes
</session-timeout>
</session-config>
c. httpRequest.getSession( ).close( ) d.
<session-config> httpRequest.getSession( ).invalidate( )
<session-timeout>time_in_minutes <session-config>
</session-timeout> <session-duration>time_in_minutes
</session-config> </session-duration>
</session-config>

1 34. What are the variables defined in Dimension?


a. length and width b. height and length
c. height and width d. None of these

6 35. The include( ) method in RequestDispatcher ______________.


a. sends a request to another resource like servlet, b. includes resources of file like
JSP or html. servlet, JSP or html.
c. appends the request and response objects to the d. None of these
current servlet.

1 36. Which AWT component is not editable?


a. Button b. TextField
c. FlowLayout d. Label

3 37. Which of the following component generates ActionEvent?


a. Window b. RadioButton
c. ScrollBar d. None

1 38. Current text of Label can be obtained using __________.


a. setAlignment( ) b. getAlignment( )
c. getText( ) d. setText( )

1 39. The method ___________ places a Menu m into the MenuBar mb.
a. mb.addMenuItem(m) b. mb.addItem(m)
c. mb.add(m) d. None of these

3 40. ___________ method is used to register a keyboard event listener.


a. KeyListener( ) b. addKeyListener( )
c. addKeyListenerEvent( ) d. eventKeyboardListener( )

1 41. Which of these Components cannot be added to Frame?


a. Label b. Button
c. CheckboxGroup d. All of above

4|Page
1 42. What is use of second parameter given in Label constructor : Label(String, int)
a. Specifies height of label in terms of pixels. b. specifies width of label in terms of
pixels.
c. specifies the alignment of text in label in terms of d. Specifies maximum numbers of
pixels. characters in label.

3 43. Name the method defined in EventObject class that returns the object generated from the
event.
a. getEvent( ) b. getObject( )
c. getId( ) d. getSource( )

3 44. The MouseListener interface is used to make mouse handling.


a. True b. False

4 45. Which of the following is true about TCP protocol?


a. is reliable and connection oriented b. is unreliable but connection
oriented
c. is reliable and connectionless d. None of these

4 46. Which class defines following methods?


int getContentLength( )
long getDate( )
long getExpiration( )
a. URLConnection b. Datagram
c. Client d. None of these

4 47. Name the class which is used to create a port where the server will listen?
a. Server b. Socket
c. ServerSocket d. SocketServer

4 48. class Permission in java.security package is __________.


a. static b. abstract
c. final d. None of these

5 49. Native – protocol pure Java Driver converts _______ into the _________ directly.
a. JDBC calls, network protocol b. ODBC class, network protocol
c. ODBC class, user calls d. JDBC calls, user calls

5 50. Choose the correct syntax for getConnection( ) method.


a. public static Connection getConnection(String url, b. public static Connection
String password) throws SQLException getConnection(String name, String
password) throws SQLException
c. public static Connection getConnection(String url, d. public static Connection
String name, String password) throws SQLException getConnection(String url, String name)
throws SQLException

5 51. SQL stands for __________.


a. Structured Query Language b. Sequential Query Language
c. Structured Question Language d. Sequential Question Language

5|Page
5 52. _____________ is a table of data which represents a data from table.
a. MetaData b. ResultSetMetaData
c. ResultSet d. Statement

6 53. State true or false for following statements.


i) JavaBeans slow-down software development process.
ii) Java Servlets do not have built-in multithreaded feature.
a. false, false b. false, true
c. true, false d. true, true

6 54. ________ is a small piece of information that is passed back & forth in HTTP request &
response.
a. Servlet b. Applet
c. Cookie d. Session

6 55. Which life cycle method is used to process a client’s request?


a. start( ) b. init( )
c. service( ) d. destroy( )

6 56. A user types the URL http://www.msbte.com/result.php. Which request gets generated?
a. GET method b. POST method
c. HEAD method d. PUT method

1 57. Which of these classes can be added to any Container class, using the add method defined
in Container class?
a. Button b. CheckboxMenuItem
c. Menu d. MenuBar

2 58. From following list which is not Swing class?


a. JLabel b. JButton
c. JImageIcon d. JCheckBox

1 59. What is the use of setEchoChar( ) method?


a. to set echo in symbol form b. to set char in symbol form
c. Both A & B d. to create password in symbol form

2 60. Which component provides support for two-state buttons?


a. Button, Checkbox b. JCheckBox,JRadioButton
c. Button, MenuItem d. JCheckBox, TextField

3 61. ActionEvent is applied on ________


a. Frame b. Checkbox, Choice, List
c. Scrollbar d. Button, TextField, List, Menu

1 62. __________ method returns currently selected item in choice.


a. getSelectedItem( ) b. getSelectedElement( )
c. getSelectedIndex( ) d. getItem( )

1 63. Which statement with respect to inner class is true.

6|Page
A) It is a way of logically grouping classes that are only used in one place.
B) It increases encapsulation.
C) It can lead to more readable and maintainable code.
a. Only A statement is true. b. Only B statement is true.
c. Only C statement is true. d. All A,B and C are true.

4 64. Which methods are commonly used in ServerSocket class?


a. public OutputStream getOutputStream( ) b. public Socket accept( )
c. public synchronized void close( ) d. None of the above

4 65. Which is the proper method to retrieve the host name of local machine?
a. static InetAddress getLocalHost( ) throws b. static InetAddress
UnknownHostException getByName(String host_name ) throws
UnknownHostException
c. static InetAddress getAllByName(String host_name d. String getHostAddress( )
) throws UnknownHostException

4 66. Which constructor of DatagramPacket class are used for receiving purpose?
a. DatagramPacket(byte data[ ], int size) b. DatagramPacket(byte data[ ], int
DatagramPacket(byte data[ ], int size, size, InetAddress
int offset, int port) ip, int port)
DatagramPacket(byte data[ ], int
offset, int size,
InetAddress ip, int port)
c. DatagramPacket(byte data[ ], int size) d. All of these
DatagramPacket(byte data[ ], int size,
InetAddress ip, int port)

5 67. public class DriverManager extends ____________


a. Object b. String
c. Connection d. Statement

5 68. Which of the following method is supported by Statement interface?


a. public boolean execute(String query) b. public ResultSet
executeQuery(String query)
c. public int executeUpdate(String query) d. All of above

5 69. In following statement rs is an object of __________ interface of JDBC API.


System.out.println(rs.getString(3));
a. RowSet b. Statement
c. Connection d. ResultSet

1 70. The default layout of Applet is _______.


a. GridLayout b. CardLayout
c. FlowLayout d. BorderLayout

6 71. Apache Tomcat is ________.


a. Servlet b. Java Program
c. API d. Web server capable of running Java
programs

7|Page
6 72. What the getSession( ) method with “true” parameter will do?
a. The session is completed b. The session object is passed to
another method
c. Creates new session if, the session does not exist d. The session is exist

1 73. Java Applets are used to create ________ applications.


a. Graphical b. user interactive
c. Both A & B d. None of these

1 74. Which component of AWT provides compact, multichoice, scrolling component?


a. List b. Choice
c. Panel d. TextArea

5 75. Which is main component of JDBC API?


a. DriverManager b. Driver
c. Connection d. All of these

8|Page

You might also like