Java Mock Test Set 1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

1. public class MenuBar extends ____________.

a. MenuComponent b. MenuContainer
c. ComponentMenu d. MenuBar

2. Which of the following is true about AWT and Swing components.


a. AWT components creates a process where as swing b. AWT components creates a thread
components creates a thread where as swing components creates
a process.
c. Both AWT and Swing components creates a process. d. Both AWT and swing components
creates a thread.

3. Panel is defined as ______________.


a. The Panel class is a concrete subclass of Container. b. A Panel is a window that does not
contain titlebar, menubar and
border.
c. Panel is a superclass of Applet. d. All of the above.

4. Which package is used for import the swing components?


a. java.swing b. java.awt
c. javax.swing d. All of the above.

5. What is API?
a. Application Programming Interchange b. Application Programming
Interaction
c. Application Programming Interface d. None of these

6. What is default layout for Dialog?


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

7. The String parameter to JButton constructor ______________.


a. tell which region to put the JButton in. b. tells the color of the JButton.
c. tells what text will appear on JButton. d. tells what should happen when
JButton is pressed.

8. Which method is used to count the number of items is the List.


a. getItem( ) b. getSelectedItem( )
c. getItemCount( ) d. getCount( )

9. Which class is used for this processing method processActionEvent( ) method?


a. Button, List, MenuItem b. Button,Checkbox,Choice
c. ScrollBar, Component, Button d. None of the above.

10. Which of this package contains all the classes and methods required for event handling in Java.
a. java.applet b. java.awt
c. java.event d. java.awt.event

11. Name the method defined in EvenObject class that returns the object generated from the event.
a. getEvent( ) b. getObject( )

1|Page
c. getId( ) d. getSource( )

12. UDP stands for ___________


a. User Data Port b. User Datagram Protocol
c. Used Data Provider d. User Data Protocol

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

14. Communication using TCP protocol is ______ and ________.


a. Connection less, Iterative b. Collection less, concurrent
c. Connection oriented, Iterative d. Connection oriented, concurrent

15. Which of these is a not a factory method of InetAddress class?


a. static InetAddress getLocalHost( ) b. static InetAddress
getByName(String hostname)
c. static InetAddress getAllName(String hostname) d. static InetAddress[ ]
getAllByName(String hostname)

16. How many steps are used to connect any java application with the database using JDBC?
a. 5 b. 4
c. 3 d. 6

17. ODBC minimum SQL grammer contains______


a. Stored procedure b. Data, Time and TimeStamp only
c. create or drop View d. Insert, update, delete only

18. Which class/interface is used for an SQL statement that is executed frequently?
a. Statement b. CallableStatement
c. PreparedStatement d. None of the above

19. Which from the below use “Middle tier”.


a. 3 tier b. 4 tier
c. n – tier d. all of the above

20. A JSP page consists of which tags?


a. HTML tags b. JSP tags
c. Both A & B d. None of the above

21. Life cycle of a servlet is managed by ______


a. Servlet Context b. Servlet Container
c. Supporting protocol d. All of the above

22. Which of these interfaces define a method actionPerformed( )


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

23. The correct hierarchy for Panel is __________


a. Component – Container – Window – Panel b. Component – Container – Applet –

2|Page
Panel
c. Component – Container – Panel d. Container – Component – Panel

24. MVC architecture is _________


a. Modelling – Visual – Controller b. Model – View – Controller
c. Model – Viewable – Controller d. Many – View – Controller

25. Which is the correct constructor of GridLayout.


a. GridLayout(int a) b. GridLayout(int num_rows, int
num_columns)
c. GridLayout(int rows, int cols, int vert) d. GridLayout(int hor)

26. What does the following code do : smt = con.createStatement( )


a. A PreparedStatement object is created to send SQL b. A Statement object is created to
commands to database. send SQL commands to database.
c. A CallableStatement is created to send SQL commands to d. A Statement object is created to
database. execute parameterized SQL
commands.

27. What are the types of DialogBox?


a. Modal DialogBox b. Modal and Modeless DialogBox
c. Modam d. None of the above.

28. In the give constructor what third parameter indicates : ScrollBar s = new ScrollBar(0,10,20,0,1000);
a. size of thumb b. minimum value
c. Increment value d. Initial Value

29. Button Control implements following listener interface.


a. ItemListener b. ActionListener
c. FlowListener d. Adapter

30. To send binary output in the response, the following method of HttpServlet response many be used
to get the appropriate Writer/Stream object.
a. getStream( ) b. getOutputStream( )
c. getBianaryStream( ) d. getWriter( )

31. Which class is used to represent a single line textbox with password character facility?
a. TextField b. TextArea
c. Label d. Checkbox

32. Which kind of driver converts JDBC calls into calls on the Client API for Oracle, Sybase, Informix, IBM
DB2, or other DBMS
a. JDBC ODBC bridge + ODBC Driver b. Native API partly – Java Driver
c. JDBC – Net pure Java Driver d. Native Protocol Pure Java Driver

33. Which method executes an SQL statement that may return multiple results?
a. executeUpdate( ) b. executeQuery( )
c. execute( ) d. noExecute( )

34. Identify correct syntax of executeQuery( ) of Statement interface.

3|Page
a. public static ResultSet executeQuery( ) b. public ResultSet
executeQuery(String q)
c. public void executeQuery(String q) d. public int executeQuery(String q)

35. java.net package consists of interface __________


a. ContentHandlerFactory b. SocketImplFactory
c. FileNameMap and URLStreamHandlerFactory d. All of the above

36. IPv6 uses ________.


a. 4 groups of 8 bits each b. 4 group of 8 hexa-decimal digits
c. 8 groups of 4 digits each d. 8 groups of 4 hexa-decimal digits
each

37. Select full form of DNS.


a. Data Network System b. Domain Name System
c. Domain Name Server d. Domain Naming Service

38. What is the use of WriteUTF( ) method?


a. This method writes a string into underlying output stream. b. This method reads a sting from
underlying input stream.
c. This method writes a byte array into underlying output d. This method writes a character
stream. array into underlying output stream.

39. Clicking the closing button on the upper right corner of a frame generates a (n)-event.
a. ItemEvent b. WindowEvent
c. MouseMotionEvent d. ComponentEvent

40. To set the title to the Frame window ________ method is used.
a. void setTitle(String str) b. void setText(String str)
c. void settitle(String str) d. None of the above

41. Suppose a Panel is added to a Frame and a Button is added to the Panel. If the Frame’s font is set to
12 point Times New Roman, the panel’s font is set 10 points Times New Roman and the Button’s font is
not set. What font will be used to display the Button’s label?
a. 12 point Times New Roman b. 11 point Times New Roman
c. 10 point Times New Roman d. 9 point Times New Roman

42. Which of the following is true about FlowLayout?


a. FlowLayout can use multiple rows if the horizontal space in b. FlowLayout is the default layout
the container is too small to hold the component. manager of panel and applet.
c. It is the default layout manager for window. d. Both A & B.

43. _________ is the first Phase of Servlet Life cycle.


a. service( ) b. init( )
c. destroy( ) d. Both B & C

44. How many copies of a JSP page can be in memory at a time?


a. 1 b. 2
c. 3 d. Unlimited

4|Page
45. Which method is used to specify before any lines that used the PrintWriter?
a. setPageType( ) b. setContextType( )
c. setContentType( ) d. setResponseType( )

46. Native API converts _________ into the ________ used by DBMS.
a. JDBC API, Network Protocol b. JDBC API, Native API calls
c. JDBC API, use calls d. JDBC API, ODBC API calls

47. _________ is used to read data from a client request.


a. ServletResponse b. ServletRequest
c. Servlet d. ServletConfig

48. DELETE statement of an SQL is executed by _____________.


a. execute( ) b. executeQuery( )
c. executeUpdate( ) d. executeDelete( )

49. Which of the method can be used to output a String in an Applet?


a. display( ) b. print( )
c. drawString( ) d. transient( )

50. Which of these is a bundle of information passed between machines?


a. MIME b. Cache
c. Datagram d. Socket

51. Which of the following function is used to find the column count of the particular ResultSet.
a. getMetadata( ) b. metadata( )
c. getColumnCount( ) d. getCount( )

52. Port number for FTP is _______


a. 21 b. 23
c. 25 d. 80

53. The class which encapsulates both the numerical IP address and the domain name for that address is
_____.
a. DatagramPacket b. DatagramSocket
c. InetAddress d. ServerSocket

54. ___________ positions are the components into 5 regions east, west, south, north, center.
a. CardLayout b. BorderLayout
c. GridLayout d. FlowLayout

55. Which of the following method must be overridden in the order to handle KeyEvent.
a. keyPressed(KeyEvent obj) b. KeyReleased(KeyEvent obj)
c. KeyTyped(KeyEvent obj) d. All of these

56. 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( )

57. MouseEvent is subclass of which of the following class?

5|Page
a. ComponentEvent b. ContainerEvent
c. ItemEvent d. InputEvent

58. The _________ is an object that is notified when an event occurs.


a. Listener b. Sources
c. Event d. None of the above

59. int getServerPort( ) method ____________


a. returns the port number on which this request was received. b. returns the port name on which
the request was received.
c. returns the server number on which this request was d. returns the port number on
received. which this response/request was
received.

60. The JDBC-ODBC bridge supports how many concurrent open statements per connection ?
a. 1 b. 0
c. Does not support connection d. None of these

61. What is API?


a. Application Programming Interchange b. Application Programming
Interaction
c. Application Programming Interface d. None of these

62. Select the correct method to create CallableStatement.


a. CallableStatement prepareCall(String sql) b. CallableStatement
prepareCall(String sql, int resultset
type, int resultset_concurrency)
c. CallableStatement prepareCall(String sql, int resultset_type, d. All of the above
int resultset_concurrency, int resultset_holdability)

63. The following methods belongs to the life cycle methods of the servlet.
a. init( ) b. service( )
c. destroy( ) d. All of the above

64. Which package is used for imporing swing components?


a. java.swing b. javax.swing
c. java.awt. d. All of the above

65. Java servlet


i) is a key component of the server side java development.
ii) is a small pluggable extension to a server that enhances functionality
iii) runs only in windows OS
iv) allows developers to customize any java enabled server
a. i, ii and iii are true b. i,iii and iv are true
c. ii,iii and iv are true d. i,ii and iv are true

66. In this constructor ServerSocket(int port, int max_queue) what is the default value for max_queue?
a. 100 b. 50
c. 75 d. 80

6|Page
67. The constructor of URL can throw an exception called ______
a. MalformedUrlException b. UrlNotFoundException
c. UrlException d. UrlSourceNotFoundException

68. Which IP address is multicast IP address?


a. 192.168.2.32 b. 235.55.45.2
c. 12.22.1.2 d. None of these

69. Microsoft Access data in _______ file format.


a. .DAT b. .MDB
c. .MSSQL d. .OBJ

70. Which of the following method is used for send SQL statements?
a. Statement b. CallableStatement
c. PreparedStatement d. Both B & C

71. Panel is defined as _______


a. Panel class is a concrete sub-class of container b. A Panel is a window that does not
contain a title bar, menu bar or
border
c. Panel is the superclass of Applet d. All of above

72. Which 5 parameters uniquely identify a connection?


a. Local IP, Remote IP, Local MAC, Remote MAC and Protocol b. Local IP, Local PORT, Remote
MAC, Remote PORT and Protocol
c. Local MAC, Local PORT, Remote MAC, Remote PORT and d. Local IP, Local PORT, Remote IP,
Protocol Remote PORT and Protocol

73. What is the use of String getActionCommand( ) method of ActionEvent class?


a. to obtain the label(caption) of Button b. to obtain the reference of Button
c. to obtain object of Button d. to obtain the label(caption) and
object of Button

74. When there is a switching condition like ON or OFF, which control is used of following?
a. Button b. RadioButton
c. ToggleButton d. TextField

75. Which method is used to set password character for a TextField?


a. setPasswordCharacter( ) b. setEchoChar( )
c. setPassChar( ) d. setEchoCharacter( )

7|Page

You might also like