GOVERNMENT POLYTECHNIC, NANDURBAR
COMPUTER ENGINEERING DEPARTMENT
Unit Test – I
Course Name: COMPUTER ENGINEERING Course Code: CO5I
Semester: Five(2022-23) Subject Title: AJP Subject Code: 22517
Time: 1 Hour Marks: 20
Multiple Choice Questions
Subject: AJP Semester:CO5I
Unit 1 & 2 – Applet Programming
AWT and Swing
1. The following example shows the creation of a
import [Link].*;
import [Link].*;
public class Main extends Applet{
public void paint(Graphics g){
[Link]("Welcome in Java Applet.",40,20);
}
}
a. Banner using Applet
b. Basic Applet
c. Display clock
d. None of the above
2. From the following statements which is a drawback for Applet?
a. It works at client side so less response time
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
3. Applet works at client side so less response time
a. True
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
GOVERNMENT POLYTECHNIC, NANDURBAR
COMPUTER ENGINEERING DEPARTMENT
Unit Test – I
Course Name: COMPUTER ENGINEERING Course Code: CO5I
Semester: Five(2022-23) Subject Title: AJP Subject Code: 22517
Time: 1 Hour Marks: 20
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
d. None of the above
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
11. What is used to run an Applet?
a. An html file
b. An Applet Viewer tool(for testing purpose)
c. Both A & B
d. None of the above
12. Which is the correct order of lifecycle in an applet?
a. Applet is started,initialized,painted,destroyed,stopped
b. Applet is painted,started,stopped,initilaized,destroyed
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()
14. All Applets must import [Link] and [Link].
a. True
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()
d. None of the above
17. [Link] defines how many interfaces?
a. 2
b. 3
c. 4
d. 5
18. Which applet [Link] class provides the life cycle method?
a. public void paint(Graphics g)
b. public void destroy()
c. public void stop()
d. public void init()
19. Which is invoked after the init() method or browser is maximized?
a. public void start()
b. public void paint(Graphics g)
c. Public void stop()
d. Public void init()
20. Applet runs inside the browser and works at client side
a. True
b. False
21. Which of these functions is called to display the output of an applet?
a. display()
b. paint()
c. displayApplet()
d. printApplet()
22. Which of these methods can be used to output a string in an applet?
a. display()
b. print()
c. drawString()
d. transient()
23. Which of these methods is a part of Abstract Window Toolkit (AWT) ?
a. display()
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
25. What is output of following program ?
import [Link].*;
import [Link].*;
public class myapplet extends Applet
{
public void paint(Graphics g)
{
[Link]("A Simple Applet", 20, 20);
}
}
a. A Simple Applet
b. A Simple Applet 20 20
c. Compilation Error
d. Runtime Error
26. What does AWT stands for?
a. All Window Tools
b. All Writing Tools
c. Abstract Window Toolkit
d. Abstract Writing Toolkit
27. What is the length of the application box made by this program?
import [Link].*;
import [Link].*;
public class myapplet extends Applet {
Graphic g;
[Link]("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
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
[Link] file?
a. <APPLET CODE = "[Link]"></APPLET>
b. <APPLET CODE="[Link]" WIDTH=250 HEIGHT=200>
c. <applet code="[Link]" width=250 height=200></applet>
d. <applet code="MyApplet" height =”250” width =”200”></applet>
33. The class at the top of the AWT hierarchy is
a. Component
b. Window
c. Container
d. Frame
34. Which package provides many event classes and Listener interfaces for event handling?
a. [Link]
b. [Link]
c. [Link]
d. [Link]
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
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
37. Which is/are used to create a Frame?
i. By creating the object of Frame Class(association)
ii. By extending Frame class(inheritance)
b. Only i
c. Only ii
d. Both
e. None
38. Which of the following methods can be used to change the size of a [Link]
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. [Link]( 300, 200 );
b. [Link]( 300, 200 );
c. [Link]( 300, 200 );
d. [Link]( 300, 200 );
40. Fill in the blanks so that this program displays a Frame:
import [Link].*;
public class microGUI
{
public static void main ( String[] args )
{
Frame frm = new ( );
frm. ( 150, 100 );
frm. ( true );
}
}
a. Form, setVisible, setOn
b. Frame, setSize, setVisible
c. Frame, setVisible, setSize
d. Window, setSize, paint
41. Which package provides many methods for graphics programming?
a. [Link]
b. [Link]
c. [Link]
d. [Link]
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.
c. Register the source(s) to receive notifications about specific type of event(s).
d. Adding mouse motion listener in the main() 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.
b. The KeyListener should be added either in init() or the main method.
c. RequestFocus should be added either in init() or the main method.
d. The class InputEvent should be imported explicitly in the program.
44. Which of the following package supports event handling routine, when we use Swing
components in GUI programs?
a. [Link]
b. [Link]
c. [Link]
d. [Link]
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
48. The MouseListener interface specifies the following methods: mouseClicked,
mouseEntered, mouse-Exited, mousePressed, and mouseReleased. In order to use a
MouseListener in your code, you must provide an implementation for which of the
following?
a. None of the MouseListener methods.
b. All MouseListener methods.
c. At least the mouseClicked method
d. Any one MouseListener method
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
50. Where are the following four methods commonly used?
1) public void add(Component c)
2) public void setSize(int width,int height)
3) public void setLayout(LayoutManager m)
4) public void setVisible(boolean)
a. Graphics class
b. Component class
c. Both A & B
d. None of the above
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)
b. public abstract void setColor(Color c)
c. public abstract void drawString(String str, int x, int y)
d. None of the above
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)
b. public abstract void fillRect(int x, int y, int width, int height)
c. public abstract void drawLine(int x1, int y1, int x2, int y2)
d. public abstract void drawOval(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
c. List
d. Checkbox
55. Which class is used for this Processing Method processActionEvent( )?
a. Button,List,MenuItem
b. Button,Checkbox,Choice
c. Scrollbar,Component,Button
d. None of the above
56. Which method can set or change the text in a Label?
a. setText()
b. getText()
c. All the above
d. None of the above
57. The following
a) It is lightweight.
b) It supports pluggable look and feel.
c) It follows MVC (Model View Controller) architecture
are the advantages of .
a. Swing
b. AWT
c. Both A & B
d. None of the above
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. [Link]
b. [Link]
c. [Link]
d. None of the above
60. The Following steps are required to perform
1) Implement the Listener interface and overrides its methods
2) Register the component with the Listener
a. Exception Handling
b. String Handling
c. Event Handling
d. None of the above
61. Where can the event handling code be written?
a. Same class
b. Other class
c. Anonymous class
d. All mentioned above
62. AWT is used for GUI programming in java
a. True
b. False
63. The ActionListener interface is not used for handling action events
a. True
b. False
Unit-3 JDBC
64. What is JDBC?
a. JDBC is a java based protocol.
b. JDBC is a standard Java API for database-independent connectivity between the
Java programming language and a wide range of databases.
c. JDBC is a specification to tell how to connect to a database.
d. Joint Driver for Basic Connection
65. Which of the following manages a list of database drivers in JDBC?
a. DriverManager
b. JDBC driver
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
67. Which of the following is correct about JDBC?
a. JDBC architecture decouples an abstraction from its implementation.
b. JDBC follows a bridge design pattern.
c. Both of the above.
d. None of the above.
68. Which of the following step establishes a connection with a database?
a. Import packages containing the JDBC classes needed for database programming.
b. Register the JDBC driver, so that you can open a communications channel with
the database.
c. Open a connection using the [Link] () method.
d. Execute a query using an object of type Statement.
69. Which of the following is true about JDBC?
a. The JDBC API is an API to access different relational databases.
b. You use it to access relational databases without embedding a dependency on a
specific database type in your code.
c. JDBC stands for Java DataBase Connectivity.
d. All of the above.
70. Which of the following is advantage of using JDBC connection pool?
a. Slow performance
b. Using more memory
c. Using less memory
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)
c. public static Connection getConnection(String url)
d. public static Connection getConnection(String url,String userName,String
password)
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
d. Native protocol 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 [Link] 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
b. The JDBC driver test suite
c. The JDBC-ODBC bridge
d. All mentioned above
77. Which class has traditionally been the backbone of the JDBC architecture?
a. the JDBC driver manager
b. the JDBC driver test suite
c. the JDBC-ODBC bridge
d. All mentioned above
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
80. 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
81. Which JDBC drivers will run your program?
a. The JDBC-ODBC bridge
b. The JDBC driver manager
c. The JDBC driver test suite
d. None of the above
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
c. ODBC written in C++ language
d. None of the above
83. A leading database connectivity vendor, worked together to produce the .
a. JDBC-ODBC Bridge
b. JDBC Driver Test Suite
c. Both A & B
d. None of the above
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
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
88. Which driver uses ODBC driver to connect to the database?
a. JDBC-ODBC bridge driver
b. Native - API driver
c. Network Protocol driver
d. Thin driver
89. How many JDBC product components does the Java software provides?
a. 3
b. 2
c. 4
d. 5
90. How many types of JDBC drivers are available?
a. 3
b. 4
c. 2
d. 5
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
c. All of the above
d. None of the above
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
d. None of 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
96. Servlets handle multiple simultaneous requests by using threads.
a. True
b. False
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
98. The sendRedirect() method of HttpServletResponse interface can be used to redirect
response to another resource, it may be servlet, jsp or html file
a. True
b. False
99. Which packages represent interfaces and classes for servlet API?
a. [Link]
b. [Link]
c. Both A & B
d. None of the above
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
101. Which HTTP Request method is non-idempotent?
a. GET
b. POST
c. Both A & B
d. None of the above
102. Which object is created by the web container at time of deploying the project?
a. ServletConfig
b. ServletContext
c. Both A & B
d. None of the above
103. What is the lifecycle of a servlet?
a. Servlet class is loaded
b. Servlet instance is created
c. init,Service,destroy method is invoked
d. All mentioned 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
d. Hidden form fields
105. Which are the examples of Application Server?
a. Apache
b. Tomcat
c. JBoss
d. Weblogic
106. How many techniques are used in Session Tracking?
a. 4
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
108. In the following statements identify the disadvantages of CGI?
a. If number of clients increases, it takes more time for sending response
b. For each request, it starts a process and Web server is limited to start processes
c. It uses platform dependent language e.g. C, C++, perl
d. All mentioned above
109. Servlet technology is used to create web application
a. True
b. False
110. Which method is used to specify before any lines that uses the PintWriter?
a. setPageType()
b. setContextType()
c. setContentType()
d. setResponseType()
111. What are functions of Servlet container?
a. Lifecycle management
b. Communication Support
c. Multithreading Support
d. All of the above
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
d. All mentioned above
113. Which methods are used to bind the objects on HttpSession instance and get the
objects?
a. setAttribute
b. getAttribute
c. Both A & B
d. None of the above
114. Which method take a string not a URL?
a. sendRedirect
b. forward
c. Both
d. None
115. Which of the following are interface? 1. ServletContext 2. Servlet 3. GenericServlet 4.
HttpServlet
a. 1,2,3,4
b. 1,2
c. 1,2,3
d. 1,4
116. The life cycle of a servlet is managed by
a. servlet context
b. servlet container
c. the supporting protocol (such as http or https)
d. All of the above
117. Which of the following code is used to get an attribute in a HTTP Session object in
servlets?
a. [Link](String name)
b. [Link](String name)
c. [Link](String name)
d. [Link](String name)
118. 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
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
119. Which are the session tracking techniques?
i. URL rewriting
ii. Using session object
[Link] 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
120. A deployment descriptor describes
a. Web component response settings
b. Web component setting
c. Web component request objects
d. All of the above
121. The values of <servlet-name> and <servlet-class> in [Link] file
a. must be same
b. must not be same
c. may be same
d. None of the above
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
b. The IsErrorPage Attribute
c. Both A & B
d. None of the above
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
124. Which of the following is an advantage of the statement – Separation of business
logic from JSP ?
a. Custom Tags in JSP
b. JSP Standard Tag Library
c. All the above
d. None of the above
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
d. None of the above
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
129. Which tag is used to execute java source code in JSP?
a. Declaration Tag
b. Scriptlet tag
c. Expression tag
d. None of the above
130. A JSP page consists of which tags?
a. HTML tags
b. JSP tags
c. Both A & B
d. None of the above
131. Which packages does a JSP API consist of?
a. [Link]
b. [Link]
c. [Link]
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
133. The difference between Servlets and JSP is the …………….
a. translation
b. compilation
c. syntax
d. Both A and B
134. Which of the following are the valid scopes in JSP?
a. request, page, session, application
b. request, page, session, global
c. response, page, session, application
d. request, page, context, application
135. JSP includes a mechanism for defining .......................................... or custom tags.
a. static attributes
b. local attributes
c. dynamic attributes
d. global attributes
136. Why DB connections are not written directly in JSPs?
a. Response is slow
b. Not a standard J2EE architecture
c. Load Balancing is not possible
d. Both B and C
137. Which is not a directive?
a. include
b. page
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
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
c. Using <%jsp:import> tag
d. Using <%jsp:useBean> tag
140. _jspService() method of HttpJspPage class should not be overridden.
a. True
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
c. Compilation, Initialization, Execution, Cleanup
d. Cleanup, Compilation, Initialization, Execution
142. Which is not a directive?
a. include
b. page
c. export
d. useBean
143. Which of the following is true about servlets?
a. Servlets execute within the address space of web server
b. Servlets are platform-independent because they are written in java
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
144. What do you mean by nameless objects?
a. An object created by using the new keyword.
b. An object of a superclass created in the subclass.
c. An object without having any name but having a reference.
d. An object that has no reference.
145. Which of the following is an immediate subclass of the Panel class?
a. Applet class
b. Window class
c. Frame class
d. Dialog class
146. Servlet are used to program which component in a web application?
a. Client
b. Server
c. Tomcat
d. Applet
147. Which class is super class in AWT Hierarchy ?
a. Container
b. List
c. Component
d. Panel
148. Which are the common security restrictions in applets?
a. Applets can't load libraries or define native methods
b. An applet can't read every system property
c. Applets can play sounds
d. Both A & B
149. Applets cannot make network connection exception to the server host from which it
originated.
a. True
b. False
150. For Event handling, what is not required?
a. Listener
b. Event Class
c. Inner class
d. Listener Interface method
151. Which Component class is not in [Link] package?
a. Button
b. TextArea
c. TextField
d. RadioButton