Professional Documents
Culture Documents
There are four principle concepts upon which object oriented design and programming rest. They
are:
1. Abstraction
2. Polymorphism
3. Inheritance
4. Encapsulation
2. What is the difference between and statement and a prepare statement in JDBC? Does the
prepared statement do anything other than allow us to have parameters (multiple uses)? How
is this different than a callable statement (used to call stored procedures)?
Statement object is used to run static SQL queries as it cannot accept the parameters.
Prepared Statement object is used to run dynamic SQL queries as it can accept parameters
at runtime.
When Statement object is used, the SQL query is not precompiled. In case of Prepared
Statement, the query is supplied to the object when it is created and it is precompiled at
that time. So it is used when the query needs to be executed many times.
It is the basic type of interface provided in java to run SQL queries. Prepared Statement
extends the Statement interface and thus provides all the features of Statement and also
the above mentioned advantages over the same.
prepared statement is compiled only once and executed many times with different
parameters avoiding delay of compilation for every retrival (execution).In prepared
statements the date formats and number formats are taken care of. Also it takes care if we
have a string with apostrophe, which otherwise needs to be escaped everytime.
Callable statement is used for SQL statements already built inside database (PL/SQL procedures
etc.) which are permanently precompiled in database
3. What is Spring?
Spring is an open source framework created to address the complexity of enterprise application
development. One of the chief advantages of the Spring framework is its layered architecture, which
allows you to be selective about which of its components you use while also providing a cohesive
framework for J2EE application development.
1. Spring has layered architecture. Use what you need and leave you don't need now.
2. Spring Enables POJO Programming. There is no behind the scene magic here. POJO programming
enables continuous integration and testability.
3. Dependency Injection and Inversion of Control Simplifies JDBC
4. Open source and no vendor lock-in.
2. What are some of the modules in Spring?
1. The core container: The core container provides the essential functionality of the Spring
framework. A primary component of the core container is the BeanFactory, an implementation of the
Factory pattern. The BeanFactory applies the Inversion of Control (IOC) pattern to separate an
application's configuration and dependency specification from the actual application code.
2. Spring context: The Spring context is a configuration file that provides context information to the
Spring framework. The Spring context includes enterprise services such as JNDI, EJB, e-mail,
internalization, validation, and scheduling functionality.
3. Spring AOP: The Spring AOP module integrates aspect-oriented programming functionality directly
into the Spring framework, through its configuration management feature. As a result you can easily
AOP-enable any object managed by the Spring framework. The Spring AOP module provides transaction
management services for objects in any Spring-based application. With Spring AOP you can incorporate
declarative transaction management into your applications without relying on EJB components.
4. Spring DAO: The Spring JDBC DAO abstraction layer offers a meaningful exception hierarchy for
managing the exception handling and error messages thrown by different database vendors. The
exception hierarchy simplifies error handling and greatly reduces the amount of exception code you
need to write, such as opening and closing connections. Spring DAO's JDBC-oriented exceptions comply
to its generic DAO exception hierarchy.
5. Spring ORM: The Spring framework plugs into several ORM frameworks to provide its Object
Relational tool, including JDO, Hibernate, and iBatis SQL Maps. All of these comply to Spring's generic
transaction and DAO exception hierarchies.
6. Spring Web module: The Web context module builds on top of the application context module,
providing contexts for Web-based applications. As a result, the Spring framework supports integration
with Jakarta Struts. The Web module also eases the tasks of handling multi-part requests and binding
request parameters to domain objects.
The main advantage of ORM like hibernate is that it shields developers from messy SQL. Apart from this,
ORM provides following benefits:
1. Improved productivity
i. High-level object-oriented API
ii. Less Java code to write
iii. No SQL to write
2. Improved performance
i. Sophisticated caching
ii. Lazy loading
iii. Eager loading
3. Improved maintainability
i. A lot less code to write
4. Improved portability
i. ORM framework generates database-specific SQL for you
4. What is differences between RESTful web services and SOAP web services?
Ans: Though both RESTful web series and SOAP web service can operate cross platform they are
architecturally different to each other, here is some of differences between REST and SOAP:
1) REST is more simple and easy to use than SOAP. REST language is based on use of nouns and verbs
(better readability)
2) REST uses HTTP protocol for producing or consuming web services while SOAP uses XML.
The SOAP WS is transport protocol neutral. Supports multiple protocols like HTTP(S), Messaging,
TCP, UDP SMTP, etc.
The REST is transport protocol specific. Supports only HTTP or HTTPS protocols.
3) REST is lightweight as compared to SOAP and preferred choice in mobile devices and PDAs. REST
does not need XML parsing, no message header (to and from), hence less bandwidth
4) REST supports different format like text, JSON and XML while SOAP only support XML.
The SOAP WS permits only XML data format. You define operations, which tunnels through the
POST. The focus is on accessing the named operations and exposing the application logic as a service.
The REST permits multiple data formats like XML, JSON data, text, HTML, etc. Any browser can be
used because the REST approach uses the standard GET, PUT, POST, and DELETE Web operations. The
focus is on accessing the named resources and exposing the data as a service. REST has AJAX support. It
can use the XMLHttpRequest object. Good for stateless CRUD (Create, Read, Update, and Delete)
operations
1. What happens if RestFull resources are accessed by multiple clients? Do you need to make it
thread-safe?
Ans: Since a new Resource instance is created for every incoming Request there is no need to make it
thread-safe or add synchronization. Multiple clients can safely access RestFull resources concurrently.
2. What are the differences between GET and POST in RESTfull Web Services?
Retrieve information. GET requests must be safe and idempotent, meaning regardless of how many
times it repeats with the same parameters, the results are the same.
POST is used to create a new entity, but it can also be used to update an entity.
3. What are the diff design approaches to create SOAP based Web Services?
Ans: Top-Down and Bottom-Up design approaches. They call it as Contract First or Contract Last.
In addition, this module supplies many enterprise services such as e-mail, JNDI access, EJB
integration, remoting, and scheduling.
Application Context Support for integration with templating frameworks such as Velocity and
FreeMarker.
Criterion API is more helpful when we have variable number of conditions in a query. The
org.hibernate.Criteria is the basic interface of criterion API for building queries.
Criteria.setProjection(Projections.Count())
Criteria.setProjection(Projections.property(userid))
10. What are the different level CACHE levels in Hibernate?
Ans: Fist Level cache & Second level cache
11. What are the different fetch strategies?
There are 4 types of fetching strategies
Fetchmode.Join (Fetch eagerly using an outer join. Equivalent to fetch="join".)
Fetchmode.Select (Fetch Lazily, using a separate select. Equivalent to fetch="select". )
Fetchmode.Subselect (Group its collection into a sub select statement
batch-size= N (Fetching up to N collections or entities)
15. How do you make sure you application code thread safe?
LOG.INFO
LOG.WARNING
LOG.CONFIG
LOG.WARNING
LOG.SEVERE