Thursday, 9 April 2015

What is LoadFactor and Importance of Load factor in java

As per java we should maintain it as .75 and initial capacity is 16.however we can increase it.
but this is the best because let we give it to Initial=100 and load factor=1
now total size to fill is 100*1=100;
two problem
1-it will take time to create 100 bucket size
2-there may be chance of waist of memory
now 16*.75=12
so advantage
1-it will take less time to crate 12
2-if at all chance of waist of memory then it would be less
again we need to increase the bucket size ,since it is create less bucket so we can bear it.not big size

more link:-
http://www.coderanch.com/t/261961/java-programmer-SCJP/certification/Default-load-factor

Saturday, 4 April 2015

java 1.5 vs 1.6 vs 1.7 vs 1.8

try with resource
http://javapapers.com/core-java/try-with-resources/
http://www.theserverside.com/tutorial/Use-try-with-resources-Language-Enhancements-for-the-Java-7-OCPJP-Exam
http://javarevisited.blogspot.in/2014/04/10-jdk-7-features-to-revisit-before-you.html
http://javarevisited.blogspot.sg/2013/04/what-is-maximum-heap-size-for-32-bit-64-JVM-Java-memory.html
---------------------
2) Java 6 Features
A feature or an enhancement in Java is encapsulated in the form of a JSR. JSR, which stands for Java Specification Request is nothing but a formal proposal which details the need for a specific functionality to be available in the JavaPlatform that can be used by Applications. These JSR’s will be reviewed and released by a committee called JavaExpert Groups (JEG). This article covers the following list of features (or JSRs') that comes along with the Java 6 Platform.
Pluggable Annotation Processing API (JSR 269)
------------------------
Common Annotations (JSR 250)
Java API for XML Based Web Services - 2.0 (JSR 224)
JAXB 2.0 (JSR 222)
Web Services Metadata (JSR 181)
Streaming API for XML (JSR 173)
XML Digital Signature (JSR 105)
Java Class File Specification Update (JSR 202)
Java Compiler API (JSR 199)
JDBC 4.0 (JSR 221)
Scripting in the Java Platform (JSR 223)
-------------------------------------------------
J2SE 5 Features

The important features of J2SE 5 are generics and assertions. Others are auto-boxing, enum, var-args, static import, for-each loop (enhanced for loop etc.

For-each loop (Java 5)
Varargs (Java 5)
Static Import (Java 5)
Autoboxing and Unboxing (Java 5)
Enum (Java 5)
Covariant Return Type (Java 5)
Annotation (Java 5)
Generics (Java 5)
---------------------------------------------------------
JavaSE 7 Features

The important features of JavaSE 7 are try with resource, catching multiple exceptions etc.

String in switch statement (Java 7)
Binary Literals (Java 7)
The try-with-resources (Java 7)
Caching Multiple Exceptions by single catch (Java 7)
Underscores in Numeric Literals (Java 7)
---------------------------------------------------------------------
java 1.8:-
http://way2java.com/java-versions-2/jdk-1-8-features/

Sunday, 29 March 2015

Why can't I define a static method in a Java interface?

There are two questions here:
  1. Why can't interfaces contain static methods?
  2. Why can't static methods be overridden?

Tuesday, 10 March 2015

What is ServletRequestWrapper and How do we use it.

public class ServletRequestWrapper
extends java.lang.Object
implements ServletRequest
Provides a convenient implementation of the ServletRequest interface that can be subclassed by developers wishing to adapt the request to a Servlet. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped request object.
more:-

https://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequestWrapper.html


This is the Best Link to knwo more about ServeltRequestWrapper


https://vangjee.wordpress.com/2009/02/25/how-to-modify-request-headers-in-a-j2ee-web-application/

Tuesday, 3 March 2015

Jdbc 3.0 vs Jdbc 4.0

Jdbc 3.0:-
Jdbc RowSet We have done the great discussion on JdbcRowSet in the previous page.
Savepoint in transaction management Now you are able to create, rollback and release the savepoint by Connection.setSavepoint(), Connection.rollback(Savepoint svpt) and Connection.releaseSavepoint(Savepoint svpt) methods.
Statement and ResultSet Caching for Connection Pooling Now you are able to reuse the statement and result set because jdbc 3 provides you the facility of statement caching and result set caching.
Switching between Global and Local Transactions
Retrieval of auto generated keys Now you are able to get the auto generated keys by the method getGeneratedKeys().

Jdbc 4.0:-
The important features of JDBC API 4.0 are given below:
Automatic Loading of Driver class You don't need to write Class.forName() now because it is loaded bydefault since jdbc4.
Subclasses of SQLException Jdbc 4 provides new subclasses of SQLException class for better readability and handling.
New methods There are many new methods introduced in Connection, PreparedStatement, CallableStatement, ResultSet etc.
Improved DataSource Now data source implementation is improved.
Event Handling support in Statement for Connection Pooling Now Connection Pooling can
listen statement error and statement closing events.

Working with the JDBC RowSet API

ntroduction

RowSet interface is basically an extension of JDBC ResultSet and is a part of thejavax.sql package. Built on the standard contextual structure of the JavaBeans component model, the core design structure is inherently reflected in the subjectivity of RowSet interface. It makes sense that RowSet has a set of JavaBeans properties, which can be set and retrieved with the available setter and getter methods. In addition to that RowSet also implements the JavaBeans mechanism of event notification that allows other components registered to the instance to receive notification when a certain event is triggered. These additional capabilities make it more flexible and leverage productivity when used effectively. In this article we shall try to get a glimpse of what RowSet is all about and how to implement one in Java.

Types of RowSet

There are two types of RowSet objects – connected and disconnected. Connected RowSet are those which establish a connection with the database and retain it until the application terminates. Disconnected RowSet on the other hand establishes a connection, executes a query such as retrieving data from the database and closes the connection.

more you can get from here:-

Why Need of serialization in Java

Serialization is usually used When the need arises to send your data over network or stored in files. By data I mean objects and not text.
Now the problem is your Network infrastructure and your Hard disk are hardware components that understand bits and bytes but not JAVA objects.
Serialization is the translation of your Java object's values/states to bytes to send it over network or save it.
This is analogous to how your voice is transmitted over PSTN telephone lines...
---------------
  • A webservice requires serialization of objects to xml before they can be transmitted.