0% found this document useful (0 votes)
20 views

Advanced-Java (Set 1)

Uploaded by

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

Advanced-Java (Set 1)

Uploaded by

chetandandekara
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Advanced JAVA

1 of 3 sets

Chapter: JAVA Networking

1. Which of these package contains classes and interfaces for networking?


A. java.io
B. java.util
C. java.net
D. javax.swing
Answer:C

2. In the following URL, identify the protocol identifier?


o m
https://mcqmate.com:8080/course.php
. c
A. http
te
B. gtu.ac.in
a
C. //mcqmate.com:80/course.php
q M
D. 8080
c
Answer:A
M
3. Which of the following protocol follows connection less service?
A. TCP
B. TCP/IP
C. UDP
D. HTTP
Answer:C

4. Which of the following statement is NOT true?


A. TCP is a reliable but slow.
B. UDP is not reliable but fast.
C. File Transfer Protocol (FTP) is a standard Internet protocol for transmitting files between
computers on the Internet over TCP/IP connections.
D. In HTTP, all communication between two computers are encrypted
Answer:D

5. Which of the following statement is TRUE?


A. With stream sockets there is no need to establish any connection and data flows between the
processes are as continuous streams.
B. Stream sockets are said to provide a connection-less service and UDP protocol is used
C. Datagram sockets are said to provide a connection-oriented service and TCP protocol is used
D. With datagram sockets there is no need to establish any connection and data flows between
the processes are as packets.
Answer:D

6. Which of the following method call is valid to obtain the server's hostname by
invoking an applet?
A. getCodeBase().host()
B. getCodeBase().getHost()
C. getCodeBase().hostName()
D. getCodeBase().getHostName()
Answer:B

7. The server listens for a connection request from a client using which of the
following statement?
A. Socket s = new Socket(ServerName, port);
B. Socket s = serverSocket.accept()
C. Socket s = serverSocket.getSocket()
D. Socket s = new Socket(ServerName);
Answer:B

8. The client requests a connection to a server using which of the following


statement?
A. Socket s = new Socket(ServerName, port);
B. Socket s = serverSocket.accept();
C. Socket s = serverSocket.getSocket();
D. Socket s = new Socket(ServerName);
Answer:A

View all MCQ's at McqMate.com


9. To connect to a server running on the same machine with the client, which of the
following cannotbe used for the hostname?
A. “localhost”
B. "127.0.0.1"
C. InetAddress.getLocalHost(),
D. "127.0.0.0"
Answer:D

10. In the socket programming, for an IP address, which can be used to find the
host name and IP address of a client/ server?
A. The ServerSocket class
B. The Socket class
C. The InetAddress class
D. The Connection interface
Answer:C

11. To create an InputStream on a socket, say s, which of the following statement is


necessary?
A. InputStream in = new InputStream(s);
B. InputStream in = s.getInputStream();
C. InputStream in = s.obtainInputStream();
D. InputStream in = s.getStream();
Answer:B

12. Which of the following protocols is/are for splitting and sending packets to an
address across a network?
A. TCP/IP
B. FTP
C. SMTP
D. UDP
Answer:A

13. Which of these is a protocol for breaking and sending packets to an address
across a network?
A. TCP/IP
B. DNS

View all MCQ's at McqMate.com


C. Socket
D. Proxy Server
Answer:A

14. Which of these class is used to encapsulate IP address and DNS?


A. DatagramPacket
B. URL
C. InetAddress
D. ContentHandler
Answer:C

15. Which of the following type of JDBC driver, is also called Type 2 JDBC driver?
A. JDBC-ODBC Bridge plus ODBC driver
B. Native-API, partly Java driver
C. JDBC-Net, pure Java driver
D. Native-protocol, pure Java driver
Answer:B

16. Which of the following type of JDBC driver, is also called Type 1 JDBC driver?
A. JDBC-ODBC Bridge plus ODBC driver
B. Native-API, partly Java driver
C. JDBC-Net, pure Java driver
D. Native-protocol, pure Java driver
Answer:A

17. Which of the following holds data retrieved from a database after you execute
an SQL query using Statement objects?
A. ResultSet
B. JDBC driver
C. Connection
D. Statement
Answer:A

18. Which of the following is not a valid type of ResultSet?


A. ResultSet.TYPE_FORWARD_ONLY
B. ResultSet.TYPE_SCROLL_INSENSITIVE

View all MCQ's at McqMate.com


C. ResultSet.TYPE_SCROLL_SENSITIVE
D. ResultSet.TYPE_BACKWARD_ONLY
Answer:D

19. Which of the following type of JDBC driver, uses database native protocol?
A. JDBC-ODBC Bridge plus ODBC driver
B. Native-API, partly Java driver
C. JDBC-Net, pure Java driver
D. Native-protocol, pure Java driver
Answer:D

20. 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
Answer:B

21. Which of the following manages a list of database drivers in JDBC?


A. DriverManager
B. JDBC driver
C. Connection
D. Statement
Answer:A

22. 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
Answer:C

23. Which of the following is correct about JDBC?


A. JDBC architecture decouples an abstraction from its implementation.

View all MCQ's at McqMate.com


B. JDBC follows a bridge design pattern.
C. Both of the above.
D. None of the above.
Answer:C

24. 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 DriverManager.getConnection () method.
D. Execute a query using an object of type Statement.
Answer:C

25. 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.
Answer:D

26. How many Result sets available with the JDBC 2.0 core API?
A. 2
B. 3
C. 4
D. 5
Answer:B

27. 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)
Answer:C

View all MCQ's at McqMate.com


28. 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
Answer:A

29. 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
C. none
D. all
Answer:A

30. The ResultSet.next method is used to move to the next row of the ResultSet,
making it the current row.
A. True
B. False
C. none
D. all
Answer:A

31. 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
Answer:D

32. 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

View all MCQ's at McqMate.com


Answer:A

33. 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
Answer:B

34. JDBC is a Java API that is used to connect and execute query to the database
A. True
B. False
C. none
D. all
Answer:A

35. 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
Answer:D

36. 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
Answer:C

37. 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

View all MCQ's at McqMate.com


C. ODBC written in C++ language
D. None of the above
Answer:B

38. 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
Answer:C

39. 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
Answer:C

40. 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
Answer:C

41. 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
Answer:B

42. The JDBC API is what allows access to a data source from a Java middle tier
A. True
B. False

View all MCQ's at McqMate.com


C. none
D. all
Answer:A

43. 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
Answer:A

44. How many JDBC product components does the Java software provides?
A. 3
B. 2
C. 4
D. 5
Answer:A

45. How many types of JDBC drivers are available?


A. 3
B. 4
C. 2
D. 5
Answer:B

46. Which method is used for an SQL statement that is executed frequently?
A. prepareStatement
B. prepareCall
C. createStatement
D. None of the above
Answer:A

Chapter: Servlet and Overview

47. How is the dynamic interception of requests and responses to transform the
information done?

View all MCQ's at McqMate.com


A. servlet container
B. servlet config
C. servlet context
D. servlet filter
Answer:D

48. 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
Answer:C

49. 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
Answer:B

50. 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
Answer:B

51. Sessions is a part of the SessionTracking and it is for maintaining the client
state at server side.
A. True
B. False
C. none
D. all

View all MCQ's at McqMate.com


Answer:A

52. When destroy() method of a filter is called?


A. The destroy() method is called only once at the end of the life cycle of a filter
B. The destroy() method is called after the filter has executed doFilter method
C. The destroy() method is called only once at the begining of the life cycle of a filter
D. The destroyer() method is called after the filter has executed
Answer:A

53. Web server is used for loading the init() method of servlet.
A. True
B. False
C. none
D. all
Answer:A

54. Servlets handle multiple simultaneous requests by using threads.


A. True
B. False
C. none
D. all
Answer:A

55. 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
Answer:A

56. 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
C. none

View all MCQ's at McqMate.com


D. all
Answer:A

57. Which packages represent interfaces and classes for servlet API?
A. javax.servlet
B. javax.servlet.http
C. Both A & B
D. None of the above
Answer:C

58. 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
Answer:A

59. Which HTTP Request method is non-idempotent?


A. GET
B. POST
C. Both A & B
D. None of the above
Answer:C

60. 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
Answer:B

61. What is the lifecycle of a servlet?


A. Servlet class is loaded
B. Servlet instance is created
C. init,Service,destroy method is invoked

View all MCQ's at McqMate.com


D. All mentioned above
Answer:D

62. 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
Answer:C

63. Which are the examples of Application Server?


A. Apache
B. Tomcat
C. JBoss
D. Weblogic
Answer:C

64. How many techniques are used in Session Tracking?


A. 4
B. 3
C. 2
D. 5
Answer:A

65. In HTTP Request method Get request is secured because data is exposed in
URL bar
A. True
B. False
C. none
D. all
Answer:B

66. 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

View all MCQ's at McqMate.com


C. It uses platform dependent language e.g. C, C++, perl
D. All mentioned above
Answer:D

67. Servlet technology is used to create web application


A. True
B. False
C. none
D. all
Answer:A

68. Which method is used to specify before any lines that uses the PintWriter?
A. setPageType()
B. setContextType()
C. setContentType()
D. setResponseType()
Answer:C

69. What are functions of Servlet container?


A. Lifecycle management
B. Communication Support
C. Multithreading Support
D. All of the above
Answer:D

70. 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
Answer:D

71. Which methods are used to bind the objects on HttpSession instance and get
the objects?
A. setAttribute

View all MCQ's at McqMate.com


B. getAttribute
C. Both A & B
D. None of the above
Answer:C

72. Which method take a string not a URL?


A. sendRedirect
B. forward
C. Both
D. None
Answer:A

73. 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
Answer:B

74. 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
Answer:B

75. 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)

View all MCQ's at McqMate.com


Answer:A

76. 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
Answer:B

77. Which are the session tracking techniques? i. URL rewriting ii. Using session
object iii.Using 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
Answer:B

78. A deployment descriptor describes


A. Web component response settings
B. Web component setting
C. Web component request objects
D. All of the above
Answer:B

79. The values of <servlet-name> and <servlet-class> in web.xml file


A. must be same
B. must not be same
C. may be same
D. None of the above
Answer:C

Chapter: JSP

View all MCQ's at McqMate.com


80. 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
Answer:C

81. 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
Answer:A

82. 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
Answer:A

83. 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
C. none
D. all
Answer:A

84. 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

View all MCQ's at McqMate.com


D. None of the above
Answer:A

85. 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
C. none
D. all
Answer:A

86. JavaServer Pages often serve the same purpose as programs implemented using
the Common Gateway Interface (CGI)
A. True
B. False
C. none
D. all
Answer:A

87. Which is the Microsoft solution for providing dynamic Web content?
A. ASP
B. JSP
C. Both A and B
D. None of the above
Answer:A

88. 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
Answer:B

89. A JSP page consists of which tags?


A. HTML tags
B. JSP tags

View all MCQ's at McqMate.com


C. Both A & B
D. None of the above
Answer:C

90. Which packages does a JSP API consist of?


A. javax.servlet.jsp
B. java.servlet
C. javax.servlet.jsp.tagext
D. Both A & C
Answer:D

91. 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
Answer:C

92. The difference between Servlets and JSP is the …………….


A. translation
B. compilation
C. syntax
D. Both A and B
Answer:C

93. 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
Answer:A

94. JSP includes a mechanism for defining …………………………. or custom tags.


A. static attributes
B. local attributes

View all MCQ's at McqMate.com


C. dynamic attributes
D. global attributes
Answer:C

95. 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
Answer:D

96. Which is not a directive?


A. include
B. page
C. export
D. taglib
Answer:C

97. Which http method send by browser that asks the server to get the page only?
A. get
B. option
C. put
D. post
Answer:A

98. 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
Answer:B

99. _jspService() method of HttpJspPage class should not be overridden.


A. True
B. False

View all MCQ's at McqMate.com


C. none
D. all
Answer:A

100. Which is not a directive?


A. include
B. page
C. export
D. useBean
Answer:C

View all MCQ's at McqMate.com

You might also like