Saturday, 18 July 2015

Java Part-08

71. What is the design pattern that Java uses for all Swing components ?

 The design pattern used by Java for all Swing components is the Model View Controller (MVC) pattern.

JDBC

72. What is JDBC ? 

JDBC is an abstraction layer that allows users to choose between databases. JDBC enables developers to write database applications in Java, without having to concern themselves with the underlying details of a particular database.

73. Explain the role of Driver in JDBC.

 The JDBC Driver provides vendor-specific implementations of the abstract classes provided by the JDBC API. Each driver must provide implementations for the following classes of the java.sql package:ConnectionStatementPreparedStatementCallableStatementResultSet and Driver.

74. What is the purpose Class.forName method ? 

This method is used to method is used to load the driver that will establish a connection to the database.

75. What is the advantage of PreparedStatement over Statement ?

 PreparedStatements are precompiled and thus,their performance is much better. Also, PreparedStatement objects can be reused with different input values to their queries.

76. What is the use of CallableStatement ? Name the method, which is used to prepare a CallableStatement

CallableStatement is used to execute stored procedures. Stored procedures are stored and offered by a database. Stored procedures may take input values from the user and may return a result. The usage of stored procedures is highly encouraged, because it offers security and modularity.The method that prepares a CallableStatement is the following:
1
CallableStament.prepareCall();

77. What does Connection pooling mean ?
 The interaction with a database can be costly, regarding the opening and closing of database connections. Especially, when the number of database clients increases, this cost is very high and a large number of resources is consumed.A pool of database connections is obtained at start up by the application server and is maintained in a pool. A request for a connection is served by a connection residing in the pool. In the end of the connection, the request is returned to the pool and can be used to satisfy future requests.

Remote Method Invocation (RMI)

78. What is RMI ?
 The Java Remote Method Invocation (Java RMI) is a Java API that performs the object-oriented equivalent of remote procedure calls (RPC), with support for direct transfer of serialized Java classes and distributed garbage collection. Remote Method Invocation (RMI) can also be seen as the process of activating a method on a remotely running object. RMI offers location transparency because a user feels that a method is executed on a locally running object. Check some RMI Tips here.

79. What is the basic principle of RMI architecture ?

 The RMI architecture is based on a very important principle which states that the definition of the behavior and the implementation of that behavior, are separate concepts. RMI allows the code that defines the behavior and the code that implements the behavior to remain separate and to run on separate JVMs.

80. What are the layers of RMI Architecture ?

 The RMI architecture consists of the following layers:
·         Stub and Skeleton layer: This layer lies just beneath the view of the developer. This layer is responsible for intercepting method calls made by the client to the interface and redirect these calls to a remote RMI Service.
·         Remote Reference Layer: The second layer of the RMI architecture deals with the interpretation of references made from the client to the server’s remote objects. This layer interprets and manages references made from clients to the remote service objects. The connection is a one-to-one (unicast) link.

·         Transport layer: This layer is responsible for connecting the two JVM participating in the service. This layer is based on TCP/IP connections between machines in a network. It provides basic connectivity, as well as some firewall penetration strategies.

No comments:

Post a Comment