22517-Mcq-Advance Java MCQ
22517-Mcq-Advance Java MCQ
22517-Mcq-Advance Java MCQ
c. Display clock
d. None of the above
b. Secured
c. It can be executed by browsers running under many platforms, including
Linux, Windows, and Mac Os etc.
d. Plugin is required at client browser to execute applet
b. False
4. The APPLET tag is used to start an applet from both an HTML document and from an
applet viewer.
a. True
b. False
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
AJAVA IMP Questions Bank
5. What invokes immediately after the start() method and also any time the applet needs to
repaint itself in the browser?
a. stop()
b. init()
c. paint()
d. destroy()
6. Which method is called only once during the run time of your applet?
a. stop()
b. paint()
c. init()
d. destroy()
7. When an applet is terminated which of the following sequence of methods calls take
place?
a. stop(),paint(),destroy()
b. destroy(),stop(),paint()
c. destroy(),stop()
d. stop(),destroy()
8. Which is a special type of program that is embedded in the webpage to generate the
dynamic content?
a. Package
b. Applet
c. Browser
9. Applet runs inside the browser and does not works at client side.
a. True
b. False
10. Java Plug-in software is not responsible to manage the lifecycle of an Applet.
a. True
b. b. False
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
AJAVA IMP Questions Bank
c. Applet is initialized,started,painted,stopped,destroyed
d. None of the above
13. Which method is used to suspend threads that don’t need to run when the applet is not
visible?
a. destroy()
b. paint()
c. stop()
d. start()
b. False
15. When an applet begins, in which sequence will the AWT call the methods?
a. init(),paint(),start()
b. Start(),paint(),init()
c. intit(),start(),paint()
d. paint(),start(),init()
16. Which method is first Called for any applet when it starts its execution?
a. void init()
b. void destroy()
c. boolean isActive()
b. 3
c. 4
d. 5
18. Which applet java.awt.component class provides the life cycle method?
a. public void paint(Graphics g)
b. public void destroy()
20. Applet runs inside the browser and works at client side
a. True
b. False
b. paint()
c. displayApplet()
d. printApplet()
b. paint()
c. drawString()
d. transient()
24. Which of these operators can be used to get run time information about an object?
a. getInfo
b. Info
c. instanceof
d. getinfoof
c. Compilation Error
d. Runtime Error
27. What is the length of the application box made by this program?
import java.awt.*;
import java.applet.*;
public class myapplet extends Applet {
Graphic g;
g.drawString("A Simple Applet", 20, 20);
}
a. 20
b. Default value
c. Compilation Error
d. Runtime Error
28. Before we try to write applets, we must make sure that Java is installed properly and also ensure
that either the java is installed properly and also ensure that either the java …………….. or a
java-enabled browser is available.
a. viewer( )
b. appletviewer( )
c. appletrunner( )
d. browserviewer( )
29. We can change the text to be displayed by an applet by supplying new text to be displayed by
an applet by supplying new text to the applet through a ……………………… tag.
a. <EDIT>
b. <CHANGE>
c. <REPLACE>
d. <PARAM>
30. The ……………….. attribute of applet tag specifies the amount of horizontal blank space the
browser should leave surrounding the applet.
a. SPACE=pixels
b. HSPACE=piexls
c. HWIDTH=piexls
d. HBLANK=pixels
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
AJAVA IMP Questions Bank
31. Which is a required attribute that gives the name of the file containing your applet’s
compiled .class file?
a. CODE
b. CODEBASE
c. ALT
d. NAME
32. Which of the following is a valid HTML file to run an applet program store in
MyApplet.java file?
a. <APPLET CODE = "MyApplet.class"></APPLET>
b. <APPLET CODE="MyApplet.java" WIDTH=250 HEIGHT=200>
b. Window
c. Container
d. Frame
34. Which package provides many event classes and Listener interfaces for event handling?
a. java.awt
b. java.lang
c. java.io
d. java.lang
35. Name the class which is used to represent a GUI application window, and is optionally
resizable and can have a title bar, an icon. Select the correct answer in the following.
a. Window
b. Panel
c. Dialog
d. Frame
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
AJAVA IMP Questions Bank
36. Which class can be used to represent a checkbox with a textual label that can appear in a
menu. Select the one correct answer.
a. MenuBar
b. MenuItem
c. CheckboxMenuItem
d. Menu
c. Only ii
d. Both
e. None
38. Which of the following methods can be used to change the size of a java.awt.Component
object?
a. dimension()
b. setSize()
c. resize()
d. size()
39. Which of the following sets the frame, say frame to 300 pixels wide by 200 high?
a. fram.setSize( 300, 200 );
b. fram.setSize( 300, 200 );
import java.awt.*;
public class microGUI
{
public static void main ( String[] args )
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
AJAVA IMP Questions Bank
{
Frame frm = new ___________( );
frm.___________( 150, 100 );
frm.___________( true );
}
}
a. Form, setVisible, setOn
b. Frame, setSize, setVisible
c. Frame, setVisible, setSize
d. Window, setSize, paint
c. java.Graphics
d. java.io
42. Which of the following steps are must for any kind of event handling?
a. Implement the listener method(s) to receive and process event related
notifications
b. Adding mouse listener in the init() method.
43. Which of the following is/ are not related with keyboard event?
a. ClassKeyEvent is used to notify if any key pressed occurs or not.
44. Which of the following package supports event handling routine, when we use Swing
components in GUI programs?
a. javax.swing
b. java.awt
c. java.util
d. java.applet
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
AJAVA IMP Questions Bank
45. Which of the following displays components row-by-row in the order in which they were
added to the JFrame?
a. CardLayout
b. FlowLayout
c. BorderLayout
d. GridLayout
46. Using a FlowLayout manager, which is the correct way to add elements to a container?
a. add (component);
b. add("Center", component);
c. add(x, y, component);
d. set(component);
47. Which layout manager places components in one of five regions: north, south, east, west,
and center?
a. CardLayout
b. FlowLayout
c. BorderLayout
d. GridLayout
49. Which class is used to create a pop-up list of items from which the user may choose?
a. JList
b. JChoice
c. JLabels
d. JCheckbox
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
AJAVA IMP Questions Bank
a. Graphics class
b. Component class
c. Both A & B
51. Which is the container that doesn't contain title bar and MenuBars but it can have other
components like button, textfield etc?
a. Window
b. Frame
c. Panel
d. Container
52. Which method is used to set the graphics current color to the specified color in the
graphics class?
a. public abstract void setFont(Font font)
53. In Graphics class which method is used to draws a rectangle with the specified width and
height?
a. public void drawRect(int x, int y, int width, int height)
54. Which object can be constructed to show any number of choices in the visible window?
a. Labels
b. Choice
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
AJAVA IMP Questions Bank
c. List
d. Checkbox
b. Button,Checkbox,Choice
c. Scrollbar,Component,Button
b. AWT
c. Both A & B
58. The ActionListener interface is not used for handling action events.
a. True
b. False
59. Which package provides many event classes and Listener interfaces for event handling?
a. java.awt
b. java.awt.Graphics
c. java.awt.event
c. Event Handling
d. None of the above
b. Other class
c. Anonymous class
63. The ActionListener interface is not used for handling action events
a. True
b. False
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
AJAVA IMP Questions Bank
Unit-3 JDBC
c. Connection
d. Statement
66. Which of the following type of JDBC driver should be used if your Java application is
accessing multiple types of databases at the same time?
a. Type 1
b. Type 2
c. Type 3
d. Type 4
b. Register the JDBC driver, so that you can open a communications channel with
the database.
d. Better performance
71. How many Result sets available with the JDBC 2.0 core API?
a. 2
b. 3
c. 4
d. 5
72. 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)
73. Which driver Network connection is indirect that a JDBC client makes to a middleware
process that acts as a bridge to the DBMS server?
a. JDBC-Net
b. JDBC-ODBC bridge
c. Native API as basis
74. JDBC RowSet is the wrapper of ResultSet,It holds tabular data like ResultSet but it is
easy and flexible to use.
a. True
b. False
75. The ResultSet.next method is used to move to the next row of the ResultSet, making it the
current row.
a. True
b. False
76. Which JDBC product components does the Java software provide?
a. The JDBC driver manager
77. Which class has traditionally been the backbone of the JDBC architecture?
a. the JDBC driver manager
b. the JDBC driver test suite
78. Which was the first most widely used programming interface for accessing relational
databases and it offers the ability to connect all the databases on all the platforms.?
a. JDBC API
b. ODBC API
c. Both A & B
d. None of the above
79. JDBC is a Java API that is used to connect and execute query to the database
a. True
b. False
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
AJAVA IMP Questions Bank
80. In the following JDBC drivers which is known as fully java driver?
a. Native-API driver
d. Both B & C
82. 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
83. A leading database connectivity vendor, worked together to produce the ____.
a. JDBC-ODBC Bridge
84. Which driver converts JDBC calls directly into the vendor-specific database protocol?
a. Native - API driver
b. Network Protocol driver
c. Thin driver
d. Both B & C
85. Which models do the JDBC API support for the database access?
a. Two-tier models
b. Three-tier models
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
AJAVA IMP Questions Bank
c. Both A & B
d. None of the above
86. Which of the following JDBC drivers is known as a partially java driver?
a. JDBC-ODBC bridge driver
b. Native-API driver
c. Network Protocol driver
d. Thin driver
87. The JDBC API is what allows access to a data source from a Java middle tier
a. True
b. False
d. Thin driver
89. How many JDBC product components does the Java software provides?
a. 3
b. 2
c. 4
d. 5
b. 4
c. 2
d. 5
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
AJAVA IMP Questions Bank
Unit – 4 Servlet
91. Which type of ServletEngine is a server that includes built-in support for servlets?
a. Add-on ServletEngin
b. Embedded ServletEngine
c. Standalone ServletEngine
d. None of the above
92. What type of servlets use these methods doGet(), doPost(),doHead, doDelete(),
doTrace()?
a. Genereic Servlets
b. HttpServlets
93. Which cookie it is valid for single session only and it is removed each time when the user
closes the browser?
a. Persistent cookie
b. Non-persistent cookie
c. All the above
94. Sessions is a part of the SessionTracking and it is for maintaining the client state at server
side.
a. True
b. False
95. Web server is used for loading the init() method of servlet.
a. True
b. False
b. False
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
AJAVA IMP Questions Bank
97. Which method is used to send the same request and response objects to another servlet in
RequestDispacher ?
a. forward()
b. sendRedirect()
c. Both A & B
d. None of the above
99. Which packages represent interfaces and classes for servlet API?
a. javax.servlet
b. javax.servlet.http
c. Both A & B
100. Which class can handle any type of request so that it is protocol-independent?
a. GenericServlet
b. HttpServle
c. Both A & B
d. None of the above
b. POST
c. Both A & B
102. Which object is created by the web container at time of deploying the project?
a. ServletConfig
b. ServletContext
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
AJAVA IMP Questions Bank
c. Both A & B
d. None of the above
104. 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?
a. HttpSession
b. URL rewriting
c. Cookies
c. JBoss
d. Weblogic
b. 3
c. 2
d. 5
107. In HTTP Request method Get request is secured because data is exposed in URL bar
a. True
b. False
b. False
110. Which method is used to specify before any lines that uses the PintWriter?
a. setPageType()
b. setContextType()
c. setContentType()
d. setResponseType()
b. Communication Support
c. Multithreading Support
112. Which object of HttpSession can be used to view and manipulate information about a
session?
a. session identifier
b. creation time
c. last accessed time
113. Which methods are used to bind the objects on HttpSession instance and get the
objects?
a. setAttribute
b. getAttribute
c. Both A & B
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
AJAVA IMP Questions Bank
c. Both
d. None
c. 1,2,3
d. 1,4
b. servlet container
c. the supporting protocol (such as http or https)
117. Which of the following code is used to get an attribute in a HTTP Session object in
servlets?
a. session.getAttribute(String name)
b. session.alterAttribute(String name)
c. session.updateAttribute(String name)
d. session.setAttribute(String name)
b. i, ii are correct
c. i, iii are correct
c. i, vi, iii, v
d. i, ii, iii, v
c. may be same
d. None of the above
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
AJAVA IMP Questions Bank
Unit – 5 JSP
122. Which attribute specifies a JSP page that should process any exceptions thrown but
not caught in the current page?
a. The ErrorPage Attribute
123. The ASP and JSP technologies are quite similar in the way they support the creation
of Dynamic pages, using HTML templates, scripting code and components for business
logic.
a. True
b. False
125. JSPs eventually are compiled into Java servlets, you can do as much with JSPs as you
can do with Java servlets.
a. True
b. False
126. JavaServer Pages often serve the same purpose as programs implemented using the
Common Gateway Interface (CGI)
a. True
b. False
127. Which technology do we mix our business logic with the presentation logic?
a. Servlet
b. JSP
c. Both A and B
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
AJAVA IMP Questions Bank
128. Which is the Microsoft solution for providing dynamic Web content?
a. ASP
b. JSP
c. Both A and B
d. None of the above
b. Scriptlet tag
c. Expression tag
c. Both A & B
d. None of the above
b. java.servlet
c. javax.servlet.jsp.tagext
d. Both A & C
132. Which of the scripting of JSP not putting content into service method of the converted
servlet?
a. Declarations
b. Scriptlets
c. Expressions
d. None of the above
a. translation
b. compilation
c. syntax
d. Both A and B
c. dynamic attributes
d. global attributes
d. Both B and C
c. export
d. taglib
138. Which http method send by browser that asks the server to get the page only?
a. get
b. option
c. put
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
AJAVA IMP Questions Bank
d. post
139. Which tag should be used to pass information from JSP to included JSP?
a. Using <%jsp:page> tag
b. Using <%jsp:param> tag
b. False
141. Which one is the correct order of phases in JSP life cycle?
a. Initialization, Cleanup, Compilation, Execution
b. Initialization, Compilation, Cleanup, Execution
b. page
c. export
d. useBean
c. Servlets can use the full functionality of the Java class libraries
d. Servlets execute within the address space of web server, platform independent
and uses the functionality of java class libraries
b. Window class
c. Frame class
d. Dialog class
b. Server
c. Tomcat
d. Applet
d. Both A & B
149. Applets cannot make network connection exception to the server host from which it
originated.
a. True
b. False
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
AJAVA IMP Questions Bank
b. Event Class
c. Inner class
c. TextField
d. RadioButton