Get 100₹ Rupees Get Now Get Now!

Advanced Java Programming (AJP) MCQs -22517 For - MSBTE Diploma computer 5th semester | I scheme

Advance Java programming mcqs msbte 22517 AJP IMP MCQs
1. Scrollbar () creates a______scroll bar by default
a) Vertical
b) Horizantal
c) Both
d) None
Ans.: a

2. is immediate super class of Menu class.
a) MenuBar
b) Menultem
c) MenuComponent
d) Object
Ans.: c

3. Which method is used to find out the number of rows in the grid layout?
a) int getRows()
b) void getRows()
c) void getRows(int)
d) None of the above
Ans.: a

4. Which of the following classes are derived from the Container class.
Select the correct answers.
a) Panel
b) Window
c) Frame
d) Component
Ans.: a

5. How could you set the frame surface color to pink ?
a) s.setBackground(Color.pink);
b) s.setColor(PINK);
c) Os.Background (pink);
d) Os.color=Color.pink
Ans.: a

6. Button B1 =new Button("Submit");Which method is used to obtain output as "Submit"
a) setText()
b) setLabel()
c) getText()
d) getLabel()
Ans.: b

7. When a ____ Dialog box is active, it blocks user input to all other windows in the program.
a) modal
b) modeless
c) file
d) none of the above
Ans.: a

8. Which of the following are true?
A. The event-inheritance model has replaced the event-delegation model.
B. The event-inheritance model is more efficient than the event-delegation model. C. The event-delegation model uses event listeners to define the methods of event handling classes.
D) The event delegation model uses the handleEvent() method to support event handling.
a) Statement A is true
b) Statement B is true
c) Statement C is true
d) Statement D is true
Ans.: c

9. Which of the following statements are used to create panel in border layout?
a) Frame p=new Frame(new BorderLayout());
b) Panel p=new Panel(); p.setLayout(new BorderLayout());
c) Panel p=new Panel();
d) Panel p = new Panel(); p. setLayout(new BorderLayout()); p. add(new Button("Okay"), BorderLayout
Ans.: d

10. The, getButton() method returns
a) returns int value that represents the button that caused the event.
b) returns boolean value that represents the button that caused the event.
c) returns void and generates events.
d) returns obiect and generates events
Ans.: c

11. JComboBox constructors are
a) JComboBox()
b) JComboBox(Vector v)
c) JComboBox(Vector v,Vector v)
d) both a and b
Ans.: d

12. Which of the following is not a swing class?
a) JComboBox
b) JFrame
c) JComponent
d) canvas
Ans.: d

13. The subclass of JToggoleButton is
a) JLabel
b) JList
c) JButton
d) JRadioButton
Ans.: d

14. Panel is a concrete subclass of
a) Window
b) Container
c) Panel
d) Frame
Ans.: b

15. Which of the following methods cannot be called on JLabel?
a) setIcon()
b) getText()
c) setLabel()
d) setBorderLayout()
Ans.: d

16. When the user press Enter key in a JTextField, the GUI component generates an which is processed by an object that implements the interface.
a) ActionEvent, ActionListener
b) ActionEvent, TextEventListener.
c) TextEvent, TextListener
d) TextEvent, ActionEventListener
Ans.: a

17. Which Swing classes can be used with progress bars?
a) JProgressBar
b) ProgressMonitor
c) ProgressMonitorInputStream
d) all the above
Ans.: a

18. What will be the following code draw on the screen. Where "g" is a graphics instance in the following code of line
g.fillArc(45,90,50,50,90,180);
a) An arc bounded by a box of height 45, width 90 with a centre point of 50,50, starting at an angle of 90 degrees traversing through 180 degrees counter clockwise.
b) An arc bounded by a box of height 50, width 50, with a centre point of 45,90 starting at an angle of 90 degrees traversing through 180 degrees clockwise.
c) An arc bounded by a box of height 50, width 50, with a top left at coordinates of 45, 90, starting at 90 degrees and traversing through 180 degrees counter clockwise.
d) An arc starting at 45 degrees, traversing through 90 degrees clockwise bounded by a box of height 50, width 50 with a centre point of 90, 180.
Ans.: c

19. Which method will cause a JFrame to get displayed?
a) show()
b) setVisible()
c) showFrame()
d) displayFrame()
Ans.: b

20. Menus are attached to the windows by calling _____ method
a) addMenus()
b) setMenu()
c) setJMenuBar()
d) addJMenuBar()
Ans.: c

21. The method getWhen() returns
a) a value that indicates which modifier keys pressed.
b) the time at which the event took place.
c) obtain the command name for the invoking ActionEvent object.
d) reference to the obiect that generated.
Ans.: b

22. Which is the abstract adapter class for receiving keyboard focus events
a) FocusListener
b) FocusAdapter
c) AdapterFocus
d) AdapterListerner
Ans.: b

23. Which of the following statements is true?
a) keyTyped() is method of KeyListener Interface
b) keyTyped() is method of MouseListener Interface
c) keyTyped() is method of ActionListener Interface
d) None of the above
Ans.: a

24. mouseExited() is method ____ interface.
a) Mouse Interface
b) MouseMotionListener Interface
c) MouseExited Interface
d) MouseListener Interface
Ans.: d

25. windowGainedFocus() and windowLostFocus() methods are belongs to interface.
a) WindowInterface
b) WindowFocused Interface
c) WindowFocusListener Interface
d) WindowAction Interface
Ans.: c

26. Which top-level class provides methods to add and remove keyboard and mouse event listeners
a) Object
b) ActionEvent
c) EventObject
d) Component
Ans.: c

27. Which are two ways to create Java Anonymous inner class?
a) Class,Interface
b) Class,Object
c) Interface, Object
d) Class, Constructor
Ans.: a

28. The WindowEvent class, WINDOW_ICONIFIED, integer constants meaning
a) Showing a window for the first time.
b) The window which contains the focus owner.
c) Reducing the window from to minimized.
d) Restoring the window to its original size.

29. In an adapter class program, if it contains 5 methods, how many methods are to be overriden?
a) 1
b) 2
c) 4
d) 5
Ans.: a

30. Can outer Java classes access inner class private members?
a) No
b) Sometimes
c) Yes
d) Never
Ans.: c

31. In Adapter class it is sufficient to include only the methods required to override.
a) True
b) False
c) Sometimes
d) Never
Ans.: a

32. The getStateChange () method returns the state change.
a) The mouse pressed or released
b) Selected or Deselected
c) A page-up or page-down
d) The window gained input focus
Ans.: b

33. which class is used to create servers that listen for either local or client program
a) ServerMachine
b) ClientMachine
c) HttpServer
d) ServerSocket
Ans.: d

34. HTTP stands for
a) Hypertext transfer processor
b) Hypertext Transfer Protocol
c) High transfer protocol
d) hyper transfer protocol
Ans.: b

35. Which of the following statement is correct?
a) The input stream of socket is connected to the output stream of remote socket
b) The output stream of socket is connected to the input stream of remote socket
c) The output stream of socket is connected to the output stream of remote socket
d) Both a & b
Ans.: d

36. Which exception will be thrown if client socket does not specify the hostname when it has created ?
a) IOException
b) UnknownHostException
c) UnknownHostNameException
d) UnknownPortException
Ans.: a

37. The Transmission Control Protocol
a) Support fast transfer of packets
b) support connectionless transport of packets
c) support unreliable transport of packets
d) support connection oriented transport of packets
Ans.: d

38. When you will use this ServerSocket(int port, int que) constructor to create server socket
a) to create ServerSocket with port number
b) to create ServerSocket with port number & Ip address
c) to create ServerSocket with port number and number of incoming client queue
d) B&C
Ans.: c

39. Which exception will occur if specified port number is not available for DatagramSoclet?
a) UnknownException
b) SocketException
c) UnknownSocketException
d) UnknownPortException
Ans.: b

40. What is the output of the following statement? ServerSocket ss=new ServerSocket(1234);
Socket s1=ss.accept();
System.out.println(s1.getPort());
a) port number of client socket
b) 1234
c) local port
d) All of the above
Ans.: a

41. Identify Correct Syntax for following method of ResulSet
_______ absolute (_____);
a) boolean, int
b) boolean, void
c) void, int
d) void, void

42. Methods of ResultSet throws
______exception.
a) IOException
b) SQLException
c) MethodNotFoundException
d) ResultSetException
Ans.: b

43. What parameter we can pass to public int getInt() method?
a) int columnIndex
b) int row
c) Both
d) None of the above
Ans.: a

44. PreparedStatement interface extends which interface?
a) Statement
b) CallableStatement
c) ResultSet
d) None of the above
Ans.: a

45. interface allows storing results of query?
a) ResultSet
b) Connection
c) Statement
d) Result
Ans.: a

46. Which method moves the cursor to the beginning of the resultset that is before first row?
a) beforeFirst()
b) afterLast()
c) first()
d) last()
Ans.: a

47. JDBC facilitates to store the java objects by using which of the methods of Prepared Statement
1. setObject()
2. setBlob()
3. setClob()
a) 1,2
b) 1,2,3
c) 1,3
d) 2,3

48. Which JDBC driver types can be used either in 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
Ans.: c

49. is the super class of all event classes.
a) Event
b) Object
c) EventObject
d) EventClass
Ans.: c

50. which of the following are the methods in belong to HttpServletRequest interface.
a) String getAuthType()
b) Cookie[] getCookies()
c) Both A and B
d) Neither A nor B
Ans.: a

51. Information that is saved for each cookie includes
a) The name, the value and expiration date of the cookie.
b) The name and expiration date of the cookie only
c) The name of Cookie only.
d) The name and the value of the cookie only
Ans.: a

52. is not removed each time when user closes the browser. It is removed only if user logout or sign out.
a) Non-persistent cookie
b) Persistent cookie
c) session
d) httpservlet
Ans.: b

53. Which of the following method of HttpServletRequest interface is used to return all the cookies from the browser.
a) Cookie getcookies()
b) private Cookie[] getCookies()
c) public Cookie[] getCookies()
d) public Cookie] setCookies()
Ans.: c

54. returns the port number to which the request was sent.
a) String getScheme()
b) String getServerName()
c) int getServerPort()
d) String getRemoteHost()
Ans.: a

55. Which of the following classes represents event notifications for changes to sessions within a web application
a) Cookie
b) HttpServlet
c) HttpSessionEvent
d) HttpSessionBindingEvent
Ans.: c

56. method indicates to the browser whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL.
a) public void setSecure(boolean flag)
b) public void setsecure(int flag)
c) private void setSecure(boolean flag)
d) public boolean setSecure(boolean flag)
Ans.: a

57. Which of the following interface declares the lifecycle method for servlet.
a) Servlet
b) Servlet Config
c) ServletContext
d) ServletResponse

58. The interface is used to indicate that only a single thread should execute the service() method of a servlet.
a) SingleThreadModel
b) UnithreadModel
c) ThreadModel
d) None of These
Ans.: a

59. Which method sets status code for this response to code
a) void setStatus(int code)
b) void setStatus()
c) void Status(int code)
d) None of the above
Ans.: a

60. Which of the following methods return an enumeration with the name of servlets in the same namespace in the server?
a) String getInitParameter(String param)
b) Enumeration getInitParameterNames()
c) Enumeration getServletNames()
d) None of these
Ans.: c

61. In case of we can implement only required methods of any interface.
a) interface
b) package
c) adapter classes
d) event classes
Ans.: c

62. What will be the output of following statements Socket s1=new Socket("localhost",1349); System.out.println(s1.getLocalPort());
a) 1349
b) port number of local machine
c) local host
d) localhost/1349
Ans.: b

61. The immediate super class of TextArea is…
a) TextField
b) TextBox
c) TextComponent
d) Component
Ans.: c

62. AWT Stands for what ?
a) Advanced Web Technology
b) Abstraction ToolKit
c) Abstract Window ToolKit
d) Abstract Windowing ToolKit
Ans.: c

63. Consider the following program and identify the missing statement.
class URLDemo
{
public static void main(String args[]) throws MalformedURLException
{
URL netAddress= new URL("http://www.sun.com:/index.html"); System.out.println("Protocol
:"+netAddress.getProtocol()); System.out.println("Port :"+netAddress.getPort()); System.out.println("Host
:"+netAddress.getHost()); System.out.println("File :"+netAddress.getFile());
}
}
a) Missing semicolon
b) Missing package statement
c) Missing initialization
d) None of the above
Ans.: b

64. The major difference between Servlet and CGI is
a) Servlets are thread based and CGI is process based.
b) Servlet executes slower than CGI.
c) Servlet has no platform specific API whereas CGI has.
d) All of these
Ans.: d

65) Who invented Java Programming ?
a) Guido van Rossum
b) James Gosling
c) Dennis Ritchie
d) Bjarne Stroustrup
Ans.: b

66. Which class can be used to represent the Checkbox with a textual label that can appear in a menu ?
A) MenuBar
B) MenuItem
C) CheckboxMenuItem
D) Menu
Ans.: c

67. What is the return type of getText( ) method of JButton class ?
A) void
B) String
C) Character array
D) There is no such method
Ans.: b

68. Which of the following is constructor for Frame class?
a) Frame()
b) Frame(String s, int how)
c) Frame(int l , int b)
d) Frame(int l, int b, String s)
Ans.: a

69. In swing MVC architecture, c stands for:
A) Controller
B) Container
C) Class
D) None of this
Ans.: a

70. Dimension class sets which of the following values?
a) length and breadth
b) length and width
c) length and height
d) width and height
Ans.: d

71. add() method is defined by which class?
a) Component
b) Container
c) Applet
d) Frame
Ans.: b

72. Action event is generated when…
a) Label is dragged
b) Button is pressed
c) Mouse is dragged
d) Window is opened
Ans.: b

73. Multiple selections are allowed in…
Menu
B. CheckboxGroup
C. List
D. Choice
Ans.: d

74. Which event is handled on Button component?
a) AdjustmentEvent
b) FocusEvent
c)KeyEvent
d)ActionEvent
Ans.: d

75. Which of the following is a passive component?
a) Label
b) Button
c) Checkbox
d) Scrollbar
Ans.: a

76. BorderLayout does not support this value of alignment…
A. BorderLayout.WEST
b) BorderLayout.EAST
c) BorderLayout.NORTH
d) BorderLayout.MIDDLE
Ans.: d

77. Is it possible to change display character of TextField? How?
a) Not possible.
b) Yes, by using setChar( ) method.
c) Yes, by using setEchoChar( ) method.
d) Yes, by using setDisplayChar( ) method.
Ans.: c

78. What is default block-increment of Scrollbar?
a) 10
b) 5
c) 1
d)We can not use block increment in scrollbars.
Ans.: d

79. What is API?
a) Application Programming Interchange
b) Application Programming Interaction
c) Application Programming Interface
d) None of these
Ans.: c

80. The setSize( ) method is defined by this class…
a) Applet
b)Component
c)Frame
d)Panel
Ans.: c

81. Which class encapsulates a blank window upon which we can draw?
a) Applet
b)Canvas
c)Window
d)Frame
Ans.: b

82. Action event is generated when…
a) Label is dragged
b) Button is pressed
c) Mouse is dragged
d) Window is opened
Ans.: b

83. At the root of Java event hierarchy, which class is located?
a) AWTEvent
b) Event
c) EventObject
d) Events
Ans.: c

84. How to remove the event listener?
a) Using removeListener() method.
b)Using removeTypeListener() method.
c) Using removeEvent( ) method.
d)It is not possible to remove the event listener.
Ans.: b

85. The correct constructor of Insets( ) which uses the values is…
a) Insets(int top, int left, int bottom, int right)
b) Insets(int bottom, int right, int top, int left)
c) Insets(int right, int top, int left, int bottom)
d)Insets(Dimesnion d1, Dimension d2)
Ans.: a

86. BorderLayout does not support this value of alignment…
a) BorderLayout.WEST
b) BorderLayout.EAST
c)BorderLayout.NORTH
d) BorderLayout.MIDDLE
Ans.: d

87. FlowLayout does not support this value of alignment…
a) FlowLayout.LEFT
b) FlowLayout.CENTER
c) FlowLayout.RIGHT
d) FlowLayout.BASELINE
Ans.: d

88. Which method is used to append the text at the end of TextArea?
a) append( )
b) add( )
c) appendAt( )
d) addAt( )
Ans.: a

89. The various controls supported by AWT are.
a) Labels, push buttons
b) Checkboxes, choice list
c) Scroll bars, text fields, text area
d) All the above
Ans.: d

90. Which of the following is a passive component?
a) Label
b) Button
c) Checkbox
d) Scrollbar
Ans.: a

91. What are the types of DialogBox?
a) Modal
b) Modal and ModeLess
c) LOAD and SAVE
d) None
Ans.: b

92.Label(String s, int how) does what?
a) Sets the string and alignment of Label b) Sets the string and alignment of caption of a Label
c) Sets the string and integer value 10
d) Sets the string and integer value 0
Ans.: b

93. Which methods are commonly used in Server Socket class?
a) Public Output Stream get Output Stream ()
b) Public Socket accept ()
c) Public synchronized void close ()
d) None of the mentioned
Ans.: b

94. What is the default alignment value for Label?
a) Label.RIGHT(2)
b) Label.CENTER(1)
c) Label.LEFT(0)
d) None
Ans.: c

95. How can the Checkbox class be used to create a radio button?
a) By associating Checkbox objects with a CheckboxGroup.
b) using RadioButton class of AWT
c) using the RoundButton class
d) None
Ans.: a

96. Which constructor of Datagram Socket class is used to create a
datagram socket and binds it with the given Port Number?
a) Datagram Socket(int port)
b) Datagram Socket(int port, Int Address address)
c) Datagram Socket()
d) None of the mentioned
Ans.: b

97. What is the default visibility of a Frame Window?
a) True
b) False
c) No such restriction
d) None
Ans.: b

98. The client in socket programming must know which information?
a) IP address of Server
b) Port number
c) Both IP address of Server & Port number
d) None of the mentioned
Ans.: c

99. Which method is used for setting caption of a Button?
a) setText(String s)
b) setText(String s, int how)
c) setLabel(String s)
d) setLabel(String s, int how)
Ans.: a

100. The URL Connection class can be used to read and write data to
the specified resource referred by the URL
a) True
b) False
Ans.: a

101. Which of the following constructor creates a TextField with 5 columns width?
a) TextField()
b) TextField(5)
c) TextField(5,5)
d) Both a and b
Ans.: d

102. Datagram is basically an information but there is no guarantee of
its content, arrival or arrival time.
a) True
b) False
Ans.: a

103. How to give editing facility to TextField?
a) setEditable(true)
b) setEditable (false)
c) setEnable (true)
d) setEnable (false)
Ans.: a

104. TCP, FTP, Telnet, SMTP, POP etc. are examples of?
a) Socket
b) IP Address
c) Protocol
d) MAC Address
Ans.: c

105. How to give password field effect to the TextField?
a) setChar(char c)
b) setEchoChar(char c)
c) setEcho(char c)
d) setCharacter(char c)
Ans.: b

106. What does the java.net.InetAddress class represent?
a) Socket
b) IP Address
c) Protocol
d) MAC Address
Ans.: b

107. How would you set the color of a graphics context called g to cyan?
a) g.setColor(Color.cyan);
b) g.setCurrentColor(cyan);c
c) g.setColor("Color.cyan");
d) g.setColor("cyan’);
Ans.: a

108. TCP,FTP,Telnet,SMTP,POP etc. are examples of ?
a) Socket
b) IP Address
c) Protocol
d) MAC Address
Ans.: c

109. In Int Address class which method returns the host name of the
IP Address?
a) Public String get Hostname()
b) Public String getHostAddress()
c) Public static IntAddress get Localhost()
d) None of the mentioned
Ans.: a

110. Which of the following is a passive component?
a) Label
b) Button
c) Checkbox
d) Scrollbar
Ans.: a

111. Which class can be used to represent the Checkbox with a textual label that can
appear in a menu?
a) MenuBar
b) MenuItem
c) CheckboxMenuItem
d) Menu
Ans.: c

112. Which are various AWT controls from following?
a) Labels, Push buttons, Check boxes, Choice lists.
b) Text components, Threads, Strings, Servelts, Vectors
c) Labels, Strings, JSP, Netbeans, Sockets
d) Push buttons, Servelts, Notepad, JSP
Ans.: a

113. JPanel and Applet use ___________________ as their default layout
a) FlowLayout
b) GridLayout
c) BorderLayout
d) GridBagLayout
Ans.: a
114. Which of the following is true about AWT and Swing Component?
a) AWT Components create a process where as Swing Component create a thread
b) AWT Components create a thread where as Swing Component create a process
c) Both AWT and Swing Component create a process
d) Both AWT and Swing Component create a thread
Ans.: a
115. Which of these methods cannot be called on JLabel object?
a) setIcon()
b) getText()
c) setLabel()
d) setBorderLayout()
Ans.: d
116. _____________ pane can be used to add component to container
a) Glass
b) Content
c) Container
d) All of above
Ans.: b
117. Which of the following is not a constructor of JTree
a) JTree(Object obj[])
b) JTree(TreeNodetn)
c) JTree(Vector v)
d) JTree(int x)
Ans.: d
118. Swing Components are_______________________
a) Platform dependent
b) Platform Independent
c) Both a & b
d) Platform oriented
Ans.: b
119. A label is a simple control which is used to display_____________ on the window:
a) Text(non-editable)
b) Text(editable)
c) Both A&B
d) None of these
Ans.: a

120. In swing MVC architecture, c stands for
A. Controller
b) Container
c) Class
d) None of this
Ans.: a
121. BorderLayout does not support this value of alignment…
a) BorderLayout.WEST
b) BorderLayout.EAST
c) BorderLayout.NORTH
d) BorderLayout.MIDDLE
Ans.: d

122. Is it possible to change display character of TextField? How?
a) Not possible.
b) Yes, by using setChar( ) method.
c) Yes, by using setEchoChar( ) method.
d) Yes, by using setDisplayChar( ) method.
Ans : c
123. What is default block-increment of Scrollbar?
a) 10
b) 5
c) 1
d) We can not use block increment in scrollbars.
Ans.: a
124. Multiple selections are allowed in…
a) Menu
b) CheckboxGroup
c) List
d) Choice
Ans.: b
125. The immediate super class of TextArea is…
a) TextField
b) TextBox
c) TextComponent
d) Component
Ans.: c
126. The CardLayout class defines the following constructors:
a) CardLayout() // First CardLayout(int hor, int ver) //second
b) Cardlayout() // First CardLayout(int hour, int ver) //second
c) CardLayout() // First Cardlayout(int hor, int var) //second
d) CardLayout() // First Cardlayout(int hour, int ver) //second
Ans.: a
127. The constructor JCheckBox(true, “YES”) suggests that –
a) Checkbox is selected and displays the string “YES” on it.
b) Checkbox is deselected and displays the string “YES” on it.
c) Checkbox is selected and it shows the tick always on it.
d) There is no such constructor.
Ans.: d

128. Which of the following constants shows scroll bars always?
a) HORIZONTAL_SCROLLBAR_ALWAYS
b) HORIZONTAL_SCROLLBAR_AS_NEEDED
c) HORIZONTAL_SCROLLBARS
d) HORIZONTAL_ALWAYS
Ans.: a
129. What is the return type of getText( ) method of JButton class?
a) void
b) String
c) Character array
d) There is no such method
Ans.: b
130. FlowLayout does not support this value of alignment…
a) FlowLayout.LEFT
b) FlowLayout.CENTER
c) FlowLayout.RIGHT
d) FlowLayout.BASELINE
Ans.: d

131. What is not true of a Java bean?
a) There are no public instance variables. b) All persistent values are accessed using getxxx and setxxx
methods.
c) It may have many constructors as necessary.
d)) All of the above are true of a Java bean.
Ans.: c

132. A JSP is transformed into
a) java applet
b) java servlet
c) both a and b
d) none of the above
Ans.: a

133. What programming language(s) or scripting language(s) does Java Server Pages (JSP) support?
a) VBScript only
b) JavaScript only
c) Java only
d) All of the above
Ans.: c

134. What servlet processor was developed by Apache Foundation and Sun?
a) Apache Tomcat
b) Apache web server
c) Sun servlet processor
d) None of the above
Ans.: a

135. What is invoked via HTTP on the Web server computer when it responds to requests from a user's Web
browser?
a) A java Application
b) A java servlet
c) A java Applet
d) all of the above
Ans.: b

136. How many copies of a JSP page can be in memory at a time?
a) 1
b) 2
c) 3
d) 4
Ans.: a

137. How does Tomcat execute a JSP?
a) As CGI Script
b) As an independent process
c) By one of the Tomcat’s Thread
d) None of the above
Ans.: c

138. The Java __________ specification defines an application programming interface for communication
between the Web server and the application program.
a) Servlet
b) Server
c) Program
d) Randomize
Ans.: a

139. The doGet() method in the example extracts values of the parameter’s type and number by using
__________
a) request.getParameter()
b) request.setParameter()
c) responce.getParameter()
d) responce.getAttribute()
Ans.: b

140. A deployment descriptor describes
a) web component response settings
b) web component settings
c) web component request objects
d) All of the above
Ans.: b

141. Dynamic interception of requests and responses to transform the information is done by
a) servlet container
b) servlet config
c) servlet context
d) servlet filter
Ans.: d

142. The life cycle of a servlet is managed by
a) servlet context
b) servlet container
c) the supporting protocol
d) All of the above
Ans.: b

143. What is the limit of data to be passed from HTML when doGet() method is used?
a) 4K
b) 8K
c) 2K
d) 1K
Ans.: c

144. The getSession() method with 'true' as its parameter [ getSession(true) ] it will return the appropriate
session object when
a) the session is completed
b) the session object is passed to another method
c) the session does not
exists
d) the session is existing
Ans.: d

145. What's the difference between servlets and applets?
1) Servlets executes on Servers, where as Applets executes on Browser
2) Servlets have no GUI, where
as an Applet has GUI
3) Servlets creates static web pages, where as Applets creates dynamic web pages
4) Servlets can handle only a single request, where as Applet can handle multiple requests
a) 1,2,3 are correct
b) 1,2 are correct
c) 1,3 are correct
d) All are correct
Ans.: b

146. Which method is used to specify before any lines that uses the PrintWriter?
a) setPageType()
b) setContextType()
c) setContentType()
d) setResponseType()
Ans.: c

147. JSP stands for __ ?
a) Java Service Page
b) Java Servlet Page
c) Java Server Page
d) None of the above
Ans.: c

148. What is a Hidden Comment in JSP?
a) <%-- --%>
b) <%-- %>
c) <%- -%>
d) <%!-- -->
Ans.: a

149. What is a Expression in JSP?
a) <%= %>
b) <%-- %>
c) <% %>
d) None of the above
Ans.: a

150. What is a Declaration in jsp?
a) <%= %>
b) <%! %>
c) <% %>
d) None of the above
Ans.: b

151. Give the abbrevation of BSD.
a. Berkeley Software Distribution
b. Berkeley Socket Distribution
c. Berkeley System Distribution
d. None of the above
Answer a

152. Label(String s, int how) does what?
a) Sets the string and alignment of Label b) Sets the string and alignment of caption of a Label
c) Sets the string and integer value 10
d) Sets the string and integer value 0
Ans.: b

153. The client in socket programming must know which
informations?
a) IPaddress of Server
b) Port number
c) Both A & B
d) None of the above
Ans.: c

154. What is the default alignment value for Label?
a) Label.RIGHT(2)
b) Label.CENTER(1)
c) Label.LEFT(0)
d) None
Ans.: c

155. The URLConnection class can be used to read and write
data to the specified resource referred by the URL
a) True
b) False
Ans.: a

156. What is the default visibility of a Frame Window?
a) True
b) False
c) No such restriction
d) None
Ans.: b

157. Datagram is basically an information but there is no
guarantee of its content, arrival or arrival time.
a. True
b. False
Ans.: a

158. Which method is used for setting caption of a Button?
a) setText(String s)
b) setText(String s, int how)
c) setLabel(String s)
d) setLabel(String s, int how)
Ans.: a

159. What does the java.net.InetAddress class represent?
a) Socket
b) IP Address
c) Protocol
d) MAC Address
Ans.: b

160. Which of the following constructor creates a TextField with 5 columns width?
a) TextField()
b) TextField(5)
c) TextField(5,5)
d) Both a and b
Ans.: d

161. Which steps occur when establishing a TCP connection
between two computers using sockets?
a) The server instantiates a ServerSocket object, denoting which
port number communication is to occur on
b) The server invokes the accept() method of the ServerSocket
class. This method waits until a client connects to the server on
the given port
c) After the server is waiting, a client instantiates a Socket object,
specifying the server name and port number to connect to
d) All of the above
Ans.: d

162. How to give editing facility to TextField?
a) setEditable(true)
b) setEditable (false)
c) setEnable (true)
d) setEnable (false)
Ans.: a

163. In InetAddress class which method returns the host
name of the IP Address?
a) public String getHostName()
b) public String getHostAddress()
c) public static InetAddress getLocalHost()
d) None of the above
Ans.: a

164. How to give password field effect to the TextField?
a) setChar(char c)
b) setEchoChar(char c)
c) setEcho(char c)
d) setCharacter(char c)
Ans.: b

165. Which type of Statement can execute parameterized queries?
a) PreparedStatement
b) ParameterizedStatement
c) ParameterizedStatement and CallableStatement
d) All kinds of Statements (i.e. which implement a sub interface of Statement)
Ans.: a

166. How to create TextArea with 2 rows and 3 columns?
a) TextArea(3,2)
b) TextArea(2,3)
c) TextArea(2)
d) TextArea(3)
Ans.: b

167. 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
Ans.: d

168. How to replace a Text from TextArea?
a) replace()
b) replaceText()
c) replaceRange()
d) replaceAll()
Ans.: c

169. 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
Ans.: a

170. How to create a List with 3 visible number of rows?
a) List()
b) List(3)
c) List(3,true)
d) List(3,3)
Ans.: b

171. 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
Ans.: c

172. Which constructor is used to give multiple mode selection facility to List?
a) List()
b) List(3)
c) List(3,true)
d) List(3,false)
Ans.: c

173. What is, in terms of JDBC, a DataSource?
a) A DataSource is the basic service for managing a set of JDBC drivers
b) A DataSource is the Java representation of a physical data source
c) A DataSource is a registry point for JNDI-services
d) A DataSource is a factory of connections to a physical data source
Ans.: d

174. Which method is used to add elements in Choice?
a) add()
b) addItem()
c) add(String s,2)
d) Both a and c
Ans.: a

175. How do you know in your Java program that a SQL warning is
generated as a result of executing a SQL statement in the database?
a) You must catch the checked SQLException which is thrown by the method which
executes the statement
b) You must catch the unchecked SQLWarningException which is thrown by the method
which executes the statement
c) You must invoke the getWarnings() method on the Statement object (or a sub
interface thereof)
d) You must query the ResultSet object about possible warnings generated by the
database
Ans.: c

176. Which of the following constructor creates a Scrollbar with Vertical Orientation ?
a) Scrollbar(4)
b) Scrollbar(1)
c) Scrollbar()
d) Scrollbar(0)
Ans.: c

177.How can you execute DML statements (i.e. insert, delete, update) in the
database?
a) By making use of the InsertStatement, DeleteStatement or UpdateStatement classes
b) By invoking the execute(…) or executeUpdate(…) method of a normal Statement
object or a sub-interface object thereof
c) By invoking the executeInsert(…), executeDelete(…) or executeUpdate(…) methods of
the DataModificationStatement object
d) By making use of the execute(…) statement of the DataModificationStatement object
Ans.: b

178. Which of the following component handles multiple events?
a) List
b) Choice
c) Scrollbar
d) TextArea
Ans.: a

179. 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(…),…
Ans.: d

180. The setLayout() method is defined by which class?
a) Applet
b) Container
c) Component
d) Frame
Ans.: b

181. Which classes are used for connection-less socket programming?
a) Datagram Socket
b) Datagram Packet
c) Both Datagram Socket & Datagram Packet
d) None of the mentioned
Ans.: c

182. Which of the following class defines accept() method?
a)Server
b)ServerSocket
c) Socket
d)ClientSocket
Ans.: b

183. In which cryptography the public and private key are used?
a) Symmetric key cryptography b)Asymmetric key cryptography
c)both a and b
d) None of the above
Ans.: b

184. Which constructor is used to create ServerSocket connected to port no 1254 and maxq length as 50.
a) ServerSocket(1254)
b)ServerSocket()
c)ServerSockect(50)
d)None of the above
Ans.: a

185. A technique that creates a subletting effect; one server answers ARP requests for multiple hosts?
a) Proxy Server
b)Proxy firewall
c)Proxy ARP
d)None of the above
Ans.: a

186. Which client accesses the Web server by using a GET MESSAGE?
a) HTTP
b) FTP
c) SMTP
d) IMTP
Ans.: a

187. Which is the connectionless protocol?
a) TCP
b) UDP
c) IP
d) HTTP
Ans.: b

188. What is the port number of HTTP?
a) 80
b) 23
c) 47
d) 92
Ans.: a

189. Which protocol that web browsers and servers use to transfer hypertext pages and images?
a) TCP/IP
b) UDP
c) HTTP
d) SMTP
Ans.: c

190. Originally, all Internet addresses consisted of ____ bit values.
a) 32
b) 16
c) 24
d) 8
Ans.: a

191. What is the full form of DNS?
a) Domain Naming System
b) Domain Naming Service
c) Domain Naming Software
d) Domain Naming Security
Ans.: a

192. What is URL?
a) Unicast Resource Location
b) Uniform Research Launcher
c) Universal Research Locator
d) Uniform Resource Locator
Ans.: d

193. Which class is used to encapsulate both the numerical IP address and the domain name for that address?
a) InetAddress
b) SocketAddress
c) IPAdress
d) DNSSockets
Ans.: a

194. Which of the following constructor of InetAddress is generally used?
a) InetAddress()
b) InetAddress(int port)
c) InetAddress(URL url)
d) There is no any visible constructor for InetAddress
Ans.: d

195. Factory method of InetAddress class throws which of the following exception?
a) MalFormedURLException
b) UnknownHostException
c) URLException
d) MalFormedURLIOException
Ans.: b

196. What type of the value that getAllByName( ) returns?
a) InetAddress[ ]
b) InetAddress
c) URL[ ]
d) URL
Ans.: a

197. Which of these is a protocol for breaking and sending packets to an address across a network?
a) TCIP/IP
b) DNS
c) Socket
d) Proxy Server
Ans.: a

198. In a web application, running in a webserver, who is responsible for creating request and
response object,
a) Web server
b) Servlet
c) Container
d) Client
Ans.: c

199. Find Errors
import java.sql.*;
class Test{
public static void main(String ar[])throws Exception
{
Class.forName(""sun.jdbc.odbc.JdbcOdbcDriver"");
System.out.println(""Drivers Loaded"");
Connection c=DriverManager.getConnection(url);
} }
a) url is not displayed
b) Connection object is created
c) url is displayed
d) No error
Ans.: a

200. Find Errors
import java.sql.*;
class Test{
public static void main(String ar[])throws Exception
{
String url=""jdbc:odbc:mydsn"";
Connection c=DriverManager.getConnection(url);
} }
a) Drivers are not loaded
b) Drivers are loaded
c) Connection is created
d) Connection is not created
Ans.: a

201. How can we create Radio buttons?
a) Using ButtonGroup class
b) Using JCheckboxGroup class
c) Using JRadioButton class
d)Using JButton class
Ans.: c

202. How to make the group of Radio buttons?
a)Using ButtonGroup class
b) Using JButtonGroup class
c) Using JRadioButton
d) Using AbstractButton class
Ans.: a

203. How to add contents of whole vector into the JComboBox?
a)Use the constructor of JComboBox
b)Use method addItem( )
c) Use method addVector( )
d) Use method addValues( )
Ans.: a

204.How to prevent the drop-down list of JComboBox?
a) It is not possible
b) We can use method preventDropMenu( ) method
c) Directly give the value false
in the constructor
d)Use setList( ) method.
Ans.: a

205.When JCheckBox is clicked the _____ event is generated.
a)ItemEvent
b) ActionEvent
c) TextEvent
d) MouseEvent
Ans.: a

206. A JSP page consists of which tags?
a) HTML tags
b) JSP tags
c) Both A & B
d) None of the above
Ans.: c

207. In JSP how many ways are there to perform exception handling?
a) 3
b) 2
c) 4
d) 5
Ans.: b

208. Which packages does a JSP API consist of?
a) javax.servlet.jsp
b) java.servlet
c) javax.servlet.jsp.tagext
d) Both a and c
Ans.: d


Advance Java programming mcqs ajp 22517 msbte



Post a Comment

Write Here Your Needs or suggestions
Have a Cookie 🍪
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using ad blocker in your browser. The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your ad blocker or allow ads from your browser's site settings.
Site is Blocked
Sorry! This site is not available in your country.