Webtech unit-IV MCQ - Mcqs PDF

Title Webtech unit-IV MCQ - Mcqs
Course Web Technology
Institution Dr. A.P.J. Abdul Kalam Technical University
Pages 31
File Size 527.4 KB
File Type PDF
Total Downloads 41
Total Views 160

Summary

Mcqs...


Description

UNIT 4 WebTech 114 MCQs 1) Which services are provided to EJB components by the EJB container? a. Transaction support b. Persistence support c. Naming support d. All mentioned above Answer : D 2) Which case of a session bean obtains the UserTransaction object via the EJBContext using the getUserTransaction() method in EJB transaction management? a. Bean-managed transactions b. Container-managed transactions c. Both A & B d. None of the above ANSWER: Bean-managed transactions 3) EJB QL is a Query Language provided for navigation across a network of enterprise beans and dependent objects defined by means of container managed persistence. a. True b. False 4) A message driven bean is like statefull session bean that encapsulates the business logic and doesn't maintain state. a. True b. False ANSWER: False 5) Abbreviate the term JMS? a. Java Message Service b. Java Monitor Service c. Java Message Session d. Java Monitor Session ANSWER: Java Message Service

6) JMS is mainly used to send and receive message from one application to another.

a. True b. False ANSWER: True

7) Which session bean maintain their state between client invocations but are not required to maintain their state across server crashes or shutdowns? a. Stateful Session Bean b. Stateless Session Bean c. Singleton Session Bean d. None of the above ANSWER: Singleton Session Bean

8) Which EJB container must provide an implementation of Java Naming and Directory Interface (JNDI) API to provide naming services for EJB clients and components? - Published on 21 Jul 15 a. Transaction support b. Persistence support c. Naming support d. All mentioned above ANSWER: Naming support

9) EJB is a specification for J2EE server, not a product; Java beans may be a graphical component in IDE. a. True b. False ANSWER: True

10) A session bean represents a multiple clients inside the Application Server. a. True b. False ANSWER: False 11) Which component does the Entity bean represent the persistent data stored in the database? - Published on 20 Jul 15 a. Server-side component

b. Client-side component c. server and client side component d. None of the above

12) EJB is a specification for J2EE server, not a product; Java beans may be a graphical component in IDE. - Published on 20 Jul 15 a. True b. False ANSWER: True

13) EJB is like COM, Abbreviate the term COM? - Published on 20 Jul 15 a. Component Object Model b. Component Oriented Model c. Common Object Model d. Common Oriented Model

ANSWER: Component Object Model

14) JMS is also known as a messaging service. - Published on 17 Jul 15 a. True b. False

ANSWER: True

15) The life cycle of session bean is not maintained by the application server (EJB Container). - Published on 17 Jul 15 a. True

b. False ANSWER: False

16) What represents a persistent global data from the database? - Published on 16 Jul 15 a. Entity Bean b. Session Bean c. Both A & B d. None of the above ANSWER: Entity Bean

17) Which component does the Entity bean represents the persistent data stored in the database? - Published on 15 Jul 15 a. Server-side component b. Client-side component c. server and client side component d. None of the above ANSWER: Server-side component

18) In EJB, middleware services are provided by EJB Container automatically. - Published on 15 Jul 15 a. True b. False ANSWER: True

19) Which middleware services are provided by EJB? - Published on 15 Jul 15 a. Security b. Transaction Management

c. Both A & B d. None of the above ANSWER: Both A & B

20) Which server-side component is required to be deployed on the server? - Published on 13 Jul 15 a. EJB b. RMI c. Both A & B d. None of the above ANSWER: EJB 21) How many types of session beans are available in EJB? - Published on 13 Jul 15 a. 2 b. 3 c. 4 d. 5 ANSWER: 3

22) Which type of instances retain no data or conversational state for a specific client? - Published on 13 Jul 15 a. Message-Driven Bean b. Session Bean c. Entity Bean d. None of the above ANSWER: Message-Driven Bean

23) Which middleware services are provided by EJB? - Published on 10 Jul 15

a. Security b. Transaction Management c. Both A & B d. None of the above ANSWER: Both A & B

24) Which session bean does the conversational state between multiple method calls is not maintained by the container? - Published on 10 Jul 15 a. Stateful Session Bean b. Stateless Session Bean c. Singleton Session Bean d. None of the above ANSWER: Stateless Session Bean

25) EJB technology is built on the top of Socket Programming - Published on 10 Jul 15 a. True b. False ANSWER: False 26) Which services are provided to EJB components by the EJB container? a. b. c. d.

Transaction support Persistence support Naming support All mentioned above

26) Which of the following is true about message driven bean? A - This type of bean stores data of a particular user for a single session. B - This is a type of enterprise bean which is invoked by EJB container when it receives a message from queue or topic. C - This type of bean represents persistent data storage.

D - None of the above. Answer: B Explanation

A message driven bean is a type of enterprise bean which is invoked by EJB container when it receives a message from queue or topic. Message driven bean is a stateless bean and is used to do task asynchronously.

27) Which of the following is true about stateless bean? A - EJB Container normally creates a pool of few stateless bean's objects and use these objects to process client's request. B - Because of pool, instance variable values are not guaranteed to be same across lookups/method calls. C - Both of the above. D - None of the above. Answer: C Explanation

EJB Container normally creates a pool of few stateless bean's objects and use these objects to process client's request. Because of pool, instance variable values are not guaranteed to be same across lookups/method calls. 28) Which of the following is correct about mappedName attribute in @javax.ejb.Stateless annotation? A - It is used to specify name of the session bean. B - it is used to specify the JNDI name of the session bean. C - It is used to provide description of the session bean. D - None of the above. Answer : B Explaination

mappedName attribute in @javax.ejb.Stateless annotation is used to specify the JNDI name of the session bean. 29) Which of the following is correct about name attribute in @javax.ejb.EJB annotation? A - It is used to specify name which will be used to locate the referenced bean in environment. B - it is used to specify the interface type of the referenced bean. C - It is used to provide name of the referenced bean. D - It is used to specify the JNDI name of the referenced bean.

Answer : A Explaination

name attribute in @javax.ejb.EJB annotation is used to specify name which will be used to locate the referenced bean in environment. 30) Which of the following annotation is used to specify Local interface(s) of a session bean? A - @javax.ejb.Stateless B - @javax.ejb.Stateful C - @javax.ejb.Local D - @javax.ejb.EJB Answer : C Explaination

@javax.ejb.Local annotation is used to specify Local interface(s) of a session bean.

31) Which of the following is correct about @PostActivate annotation for a callback method? A - Method is invoked when a bean is created for the first time. B - Method is invoked when a bean is removed from the bean pool or is destroyed. C - Method is invoked when a bean is loaded to be used. D - Method is invoked when a bean is put back to bean pool. Answer : C Explaination

@PostActivate - method is invoked when a bean is loaded to be used.

32) Which annotation is used to inject an datasource into an ejb? A - @EJB B - @Resource C - Both of the above. D - None of the above. Answer : B Explaination

@Resource annotation is used to inject an datasource into an ejb.

33) Which of the following types of java classes can be mapped using @Lob annotation? A - byte[] B - String C - Serializable Object D - All of the above. Answer : D Explaination

All of the above classes can be mapped using @Lob annotation.

34) Which of the following is correct about a Success attrribute of Bean Managed Transactions in EJB? A - When to start a transaction in a business method. B - Identify success scenario when a transaction is to be committed. C - Identify failure scenario when a transaction is to be rollback. D - None of the above. Answer : B Explaination

Success - Identify success scenario when a transaction is to be committed.

35) Which of the following is true about exceptions handling by EJB Container? A - When Application Exception occurs, ejb container intercepts the exception but returns the same to the client as it is. B - EJB Container does not roll back the transaction unless it is specified in code by EJBContext.setRollBackOnly() method. C - Both of the above D - None of the above. Answer : C Explaination

When Application Exception occurs, ejb container intercepts the exception but returns the same to the client as it is. It does not roll back the transaction unless it is specified in code by EJBContext.setRollBackOnly() method. 36) How to specify autowiring by name? Options

A : @Qualifier B : @Type C : @Constructor D : @Name View Answer 37) What does setAutoCommit(false) do? Options A : commits transaction after each query B : explicitly commits transaction C : does not commit transaction automatically after each query D : never commits transaction View Answer 39) What is the attribute of java bean to specify scope of bean to have single instance per Spring IOC? Options A : prototype B : singleton C : request D : session View Answer 40) Which attribute is used to specify destroy method? Options A : destroy B : destroy-method C : destruction D : destruction-method

41. Which of the following annotation is used to specify or inject a dependency as ejb instance into another ejb? A. javax.ejb.Stateless B. javax.ejb.Stateful C. javax.ejb.MessageDrivenBean

D. javax.ejb.EJB View Answer Workspace Report Discuss Answer & Explanation Answer: Option D Explanation:

42. The EJB specification architecture does NOT define A. transactional components B. client side security and encryption C. distributed object components D. server-side components View Answer Workspace Report Discuss Answer & Explanation Answer: Option B Explanation:

43. Which of the following is true? A. Preserving of any state across method calls does not performed by Stateless session beans B. Multiple users can access Stateful session beans at the same time C. Both are correct D. None View Answer Workspace Report Discuss

Answer & Explanation Answer: Option A Explanation:

44. Which EJB container must provide an implementation of Java Naming and Directory Interface (JNDI) API to provide naming services for EJB clients and components? A. Transaction support B. Persistence support C. Naming support D. All mentioned above View Answer Workspace Report Discuss Answer & Explanation Answer: Option C Explanation:

45. Which statement about session beans is true? A. In both stateless and statefull session classes, the bean provider must write the method public void remove() B. The method > in the component interface can be accessed only by the remote clients C. The bean’s handle must be provided by the client, in order to ask the EJBHome for removing a session bean D. None of the above View Answer Workspace Report Discuss Answer & Explanation Answer: Option C

Explanation:

46) Which of the following is correct about Statement class of JDBC? A - Statement encapsulates an SQL statement which is passed to the database to be parsed and compiled. B - Statement encapsulates an SQL statement which is passed to the database to be planned and executed. C - Both of the above. D - none of the above. Answer : C Explanation

Statement encapsulates an SQL statement which is passed to the database to be parsed, compiled, planned and executed.

47) In which of the following type of ResultSet, the cursor can only move forward in the result set? A - ResultSet.TYPE_FORWARD_ONLY B - ResultSet.TYPE_SCROLL_INSENSITIVE C - ResultSet.TYPE_SCROLL_SENSITIVE D - None of the above. Answer : A Explanation

ResultSet.TYPE_FORWARD_ONLY: The cursor can only move forward in the result set.

48) 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 Explanation

Native-protocol, pure Java driver, uses database native protocol.

49) Which of the following is not a valid type of statement in JDBC? A - Statement B - PreparedStatement C - CallableStatement D - QueryStatement Answer : D Explanation

QueryStatement is not a valid type of statement in JDBC.

50) Which of the following is correct about PreparedStatement? A - PreparedStatement allows mapping different requests with same prepared statement but different arguments to execute the same execution plan. B - Prepared statements are more secure because they use bind variables, which can prevent SQL injection attack. C - Both of the above. D - None of the above. Answer : C Explanation

PreparedStatement allows mapping different requests with same prepared statement but different arguments to execute the same execution plan. Prepared statements are more secure because they use bind variables, which can prevent SQL injection attack.

51) How does JDBC handle the data types of Java and database? A - The JDBC driver converts the Java data type to the appropriate JDBC type before sending it to the database. B - It uses a default mapping for most data types. C - Both of the above. D - None of the above. Answer : C Explanation

The JDBC driver converts the Java data type to the appropriate JDBC type before sending it to the database. It uses a default mapping for most data types. For example, a Java int is converted to an SQL INTEGER.

54) Which of the following is correct about connection pooling? A - Application server like WebLogic, WebSphere, jBoss and Tomcat provides the facilities to configure connection pooling. B - components like Apache Commons DBCP Component can be used to configure connection pooling. C - Both of the above. D - None of the above. Answer : C Explanation

If you use an application server like WebLogic, WebSphere, jBoss, Tomcat. , then your application server provides the facilities to configure for connection pooling. If you are not using an application server then components like Apache Commons DBCP Component can be used.

55) Which of the following is correct about setFetchSize(int)? A - setFetchSize(int) defines the number of rows that will be read from the database when the ResultSet needs more rows. B - setFetchSize(int) affects how the database returns the ResultSet data. C - Both of the above. D - None of the above. Answer : C Explanation

setMaxRows(int) method of the ResultSet specifies how many rows a ResultSet can contain at a time. setMaxRows(int) affects the client side JDBC object.

56) Which of the following is true about 'dirty read'? A - In typical database transactions, say one transaction reads and changes the value while the second transaction reads the value before committing or rolling back by the first transaction. This reading process is called as 'dirty read'. B - There is always a chance that the first transaction might rollback the change which causes the second transaction reads an invalid value. C - Both of the above. D - None of the above. Answer : C Explanation

In typical database transactions, say one transaction reads and changes the value while the second transaction reads the value before committing or rolling back by the first transaction. This reading process is called as 'dirty read'. Because there is always a chance that the first transaction might rollback the change which causes the second transaction reads an invalid value.

57) New drivers can be plugged-in to the JDBC API without changing the client code. A - true B - false Answer : A Explanation

New drivers can be plugged-in to the JDBC API without changing the client code. 59) What are the major components of the JDBC? DriverManager, Driver, Connection, Statement, and ResultSet DriverManager, Driver, Connection, and Statement DriverManager, Statement, and ResultSet DriverManager, Connection, Statement, and ResultSet Workspace Answer: a Explanation:

DriverManager: Manages a list of database drivers. Driver: The database communications link, handling all communication with the database. Connection: Interface with all methods for contacting a database. Statement: Encapsulates an SQL statement which is passed to the database to be parsed, compiled, planned, and executed. ResultSet: The ResultSet represents a set of rows retrieved due to query execution.

60) Select the packages in which JDBC classes are defined? A. B. C. D.

jdbc and javax.jdbc rdb and javax.rdb jdbc and java.jdbc.sql sql and javax.sql

Workspace Answer: d

Explanation: JDBC API is divided into two packages i.e. java.sql and javax.sql. We have to import

these packages to use classes and interfaces in our application.

61) Thin driver is also known as? A. B. C. D.

Type 3 Driver Type-2 Driver Type-4 Driver Type-1 Driver

Workspace Answer: c Explanation: The JDBC thin driver is a pure Java driver. It is also known as Type-4 Driver. It is

platform-independent so it does not require any additional Oracle software on the client-side. It communicates with the server using SQL *Net to access Oracle Database.

63) What is the correct sequence to create a database connection? i. Import JDBC packages. 2.7M Hello Java Program for Beginners ii. Open a connection to the database. iii. Load and register the JDBC driver. iv. Execute the statement object and return a query resultset. v. Create a statement object to perform a query. vi. Close the resultset and statement objects. vii. Process the resultset. viii. Close the connection. a) b) c) d)

i, ii, iii, v, iv, vii, viii, vi i, iii, ii, v, iv, vii, vi, viii ii, i, iii, iv, viii, vii, v, vi i, iii, ii, iv, v, vi, vii, viii

Workspace Answer: b Explanation: To create a database connection in Java, we must follow the sequence given below:

Import JDBC packages. Load and register the JDBC driver. Open a connection to the database.

Create a statement object to perform a query. Execute the statement object and return a query resultset. Process the resultset. Close the resultset and statement objects. Close the connection.

64) Which of the following method is used to perform DML statements in JDBC? a) b) c) d)

executeResult() executeQuery() executeUpdate() execute()

Answer: c Explanation: We use the executeUpdate() method for DML SQL queries that change data in the

database, such as INSERT, UPDATE, and DELETE which do not return a resultset.

65) How many transaction isolation levels provide the JDBC through the Connection interface? a) b) c) d)

3 4 7 2

Answer: b Explanation: The following table defines transaction isolation levels.

Transaction Isolation Level

Description

TRANSACTION_READ_UNCOMMITTED Dirty reads, non-repeatable reads, and phantom reads can occur. TRANSACTION_READ_COMMITTED

Dirty reads are prevented; non-repeatable reads and phan...


Similar Free PDFs