Monday 26 December 2011

Java interview questions: - How to configure tag libraries in Struts 1.xx version?

Following are the steps to configure tag libraries in Struts 1.xx version.

Manual configuration:

Used in Struts version less than or equal 1.1

Step 1:  Download struts-bean.tld, struts-html.tld, struts-logic.tld and struts-tiles.tld and put the same in WEB-INF

Step 2:  Declare the taglib uri in web.xml


And so on

Step 3: Access the same in Jsp
Automatic Configuration:

Used in Struts version 1.2, 1.3

Step 1:


Download struts-taglib.jar and put the jar in WEB-INF/lib

(All the tld are present in struts-taglib.jar\META-INF\tld)

Step 2: Access the tlds in Jsp

Also see the following interesting video on Struts: -



Know more on  Java interview questions

Regards,

Get more on Java/Struts interview questions from author’s blog



Wednesday 21 December 2011

Java interview questions: - Mention the predefined result struts.

In Struts 2 there are certain pre-defined result types which along with its function are explained as below.

Result typeFunction
Chain ResultAction Chaining
Dispatcher Result web resource integration,
includingJSP integration
FreeMarker Result FreeMarker integration
HttpHeader Result control special HTTP behaviors
Redirect Result redirect to another URL (web resource)
Redirect Action Resultredirect to another action mapping
Stream Resultstream an InputStream back to the
browser (usually for file downloads)
Velocity ResultVelocity integration
XSL ResultXML/XSLT integration
PlainTextdisplay the raw content of a particular
page (i.e jsp, HTML)
Tiles Resultprovide Tiles integration

View the following video on Bean Tag with Struts 2 as follows: -



For more on  Java interview questions, so click and visit.

Regards,

Author’s more on Java interview questions



Thursday 15 December 2011

Java interview questions: - In hibernate framework explain the core interfaces of it?

This is one of the most favorite  Java interview questions of the interviewer. So in the following way one can answer this question: -

Session Interface
This is the primary interface used by hibernate applications
The instances of this interface are lightweight and are inexpensive to create and destroy
Hibernate sessions are not thread safe

Session Factory Interface
This is a factory that delivers the session objects to hibernate application.

Configuration Interface
This interface is used to configure and bootstrap hibernate.
The instance of this interface is used by the application in order to specify the location of hbm documents

Transaction Interface
This interface abstracts the code from any kind of transaction implementations such as JDBC transaction, JTA transaction

Query and Criteria Interface
This interface allows the user to perform queries and also control the flow of the query execution

Following is the video where it is shown practically to implement Many To One relation in database using Hibernate: -



Click and get to see more on  Java/J2EE interview questions series.

Regards,

Also visit author’s blog for more Java/J2EE interview questions

Thursday 8 December 2011

Java/Struts interview questions: - Elaborate the difference between Struts 1.x and Struts 2.x

Struts 1.xStruts 2.x
Configuration of ActionServlet via servletConfiguration of FilterDispatcher is via filters
Struts1 extends the abstract base class
by its action class
Implements Action interface but not a compulsion.
 Any POJO class can behave like Action
Follows FrontController patternFollows FilterDispacther pattern
Extra care has to be taken to make resources
 thread safe because Actions are singletons
Action objects are instantiated for each request and
 hence are inherently thread safe
Testing is a problem since execute() method
exposes Servlet API
Testing is easier
ActionForms serves are inputAny POJO can serve as input
Binds objects in page using standard mechanismBinds objects using valuestack
Type conversions are using common-beanutils.jarType conversions are using OGNL
General notation for config file is Struts-config.xml
 is used
General notation for config file is struts.xml
No concept of namespaceNamespace are readily available for modularity

Also see the following interesting video on Struts: -



Know more on  Java/Struts interview questions

Regards,

Get more on Java/Struts interview questions from author’s blog

Saturday 26 November 2011

Java/Struts interview questions: - All types of Action classes in Struts.

One of the most likely questions asked in  Java/Struts interview questions. So set your answers accordingly as mentioned below.
  • ForwardAction: to do the “forward-only” and allow you to access the specified JSP page directly without going through controller.
  • IncludeAction: IncludeAction is much like ForwardAction except that the resulting resource is included in the HTTP response instead of being forwarded to
  • DispatchAction: provides a mechanism for grouping a set of related functions into a single action, thus eliminating the need to create separate actions for each functions.
  • LookupDispatchAction: provides a mechanism for grouping a set of related functions into a single action.
  • SwitchAction: This is a standard Action that switches to a new module and then forwards control to a URI within the new module.
  • DownloadAction: This is an abstract base class that minimizes the amount of special coding that needs to be written to download a file.
  • LocaleAction: Implementation of Action that changes the user's Locale and forwards to a page, based on request level parameters that are set.
  • EventDispatchAction: An Action that dispatches to to one of the public methods that are named in the parameter attribute of the corresponding ActionMapping and matches a submission parameter.
  • MappingDispatchAction: Same with Dispatch Action, group similar functionality into a single action class but with different mechanism.
  • DynoAction: Allow you to create a virtual form bean declaratively to increase the development speed.
View the following video on understanding the basics introduction to Struts: -



Click and get to see more on Java/Struts interview questions series.

Regards,

Also visit author’s blog for more Java/Struts interview questions

Sunday 20 November 2011

Java interview questions: - 14 important questions asked on String Handling.

During interview following are  Java interview questions which is asked by the interviewer. So do prepare for the interview on this 14 important questions: -
  • Is String a primitive data type in Java?
  • What is the difference between String and String Buffer?
  • Which gives more perform String or StringBuffer?
  • What is difference between string and StringTokenizer?
  • Which package does define String and StringBuffer classes?
  • Which method can be used to obtain the length of the String?
  • How do you concatenate Strings?
  • Which method can be used to compare two strings for equality?
  • Which method can be used to perform a comparison between strings that ignores case differences?
  • What is the use of valueOf( ) method?
  • What are the uses of toLowerCase( ) and toUpperCase( ) methods?
  • Which method can be used to find out the total allocated capacity of a StrinBuffer?
  • Which method can be used to set the length of the buffer within a StringBuffer object?
  • What is StringBuilder?
View the following video on tiles integration with Struts 2: -



Visit for more  Java/J2EE interview questions series.
Regards,

Also visit author’s blog for more Java/J2EE interview questions

Friday 18 November 2011

Java interview questions: - 16 most asked important questions on Input and Output (I/O).

Following are the sets of 16 most asked  Java interview questions by the interviewer during the interview.
  • What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?
  • What is the purpose of the File class?
  • What an I/O filter?
  • What is the difference between the File and RandomAccessFile classes?
  • What is Serialization and deserialization?
  • What is the difference between Serializalble and Externalizable interface?
  • Which methods of Serializable interface should I implement?
  • What is the purpose of the Runtime class?
  • What is the purpose of the System class?
  • What is the Properties class?
  • How many methods in the Externalizable interface?
  • What class allows you to read objects directly from a stream?
  • What happens to the static fields of a class during serialization?
  • How do I connect a Reader to an InputStream?
  • How many types of IOStream are present?
  • What is the use of non blocking IO?
Also see the following interesting video on Inheritance between beans and Spring: -

Know more on  Java interview questions
Regards,
Get more on Java interview questions from author’s blog

Tuesday 15 November 2011

Java/servlets interview questions: - Session tracking and methods for session tracking.

This is one of the asked Java/J2EE interview questions during an interview. So one can start proceeding with the answer as follows.

Session tracking is a mechanism that servlets use to maintain state about a series requests from the same user across some period of time

Following are the methods for session tracking: -
  • User Authentication - occurs when a web server restricts access to some of its resources to only those clients that log in using a recognized username and password.
  • Hidden form fields - fields are added to a HTML form which is not displayed in the client’s browser. When the form containing the fields is submitted, the fields are    sent back to the server.
  • URL rewriting - every URL that the user clicks on is dynamically modified or rewritten to include extra information. The extra information can be in the form of extra path information, added parameters or some custom, server-specific URL change.
  • Cookies - a bit of information that is sent by a web server to a browser and which can later be read back from that browser.
  • HttpSession- places a limit on the number of sessions that can exist in memory.

See the following video on Value List Handler as follows: -



Click and get to see more on  Java/J2EE interview questions series.

Regards,

Also visit author’s blog for more Java/J2EE interview questions

Saturday 12 November 2011

Java interview questions: - What are the functions present in Queue interface?

This is one of the typically asked  Java interview questions in most of the Java interview.
  • public boolean offer(Object element): return false if the object cannot be added to the collection due to size issue and without throwing unchecked exception.
  • public Object remove(): behaves like the Collection interface version.
  • public Object poll(): behaves just like remove() but when invoked on empty collection returns null without throwing exception.
  • public Object element(): for querying the element at the head of the queue. Throws exception when a collection is empty.
  • public Object peek(): for querying the element at the head of the queue. Returns null if the collection is empty.
Also see Batch Processing video in Hibernate of  Java interview questions



Visit for more  Java/J2EE interview questions series.

Regards,

Also visit author’s blog for more Java/J2EE interview questions

Thursday 10 November 2011

Java/J2EE interview questions: - Explanation of working thread .

One can start answering this Java/J2EE interview questions as follows: -
  • In working thread scheme, allocates one thread to execute one task.
  • When the task is complete, the thread may return to a thread pool for later use. In this scheme a thread may execute arbitrary tasks, which are passed in the form of a Runnable method argument, typically execute().
  • The runnable tasks are usually stored in a queue until a thread host is available to run them.
  • The worker thread design pattern is usually used to handle many concurrent tasks where it is not important which finishes first and no single task needs to be coordinated with another. The task queue controls how many threads run concurrently to improve the overall performance of the system. However, a worker thread framework requires relatively complex programming to set up, so should not be used where simpler threading techniques can achieve similar results.
View the following video on tiles integration with Struts 2: -



Know more on Java interview questions

Regards,

Get more on Java interview questions from author’s blog

Tuesday 8 November 2011

Java interview questions: - Mention differences between Enumeration, ArrayList, Hashtable, Collections and Collection.

Following is the differences between Enumeration, ArrayList, Hashtable, Collections and Collection for the Java interview questions asked by the interviewer.
  • Enumeration: It is series of elements. It can be use to enumerate through the elements of a vector, keys or values of a hashtable. Used for read only operations on collections.
  •  ArrayList: It is re-sizable array implementation. Implements List interface It permits all elements, including null. It is not thread -safe.
  •  Hashtable: It maps key to value. You can use non-null value for key or value. It is part of group Map in collection.
  •  Collections: It implements Polymorphic algorithms which operate on collections.
  •  Collection: It is the root interface in the collection hierarchy.
See the following video which will show us practically Inheritance between beans and Spring: -



Visit for more  Java interview questions

Regards,

Also visit for more author’s blog on Java interview questions

Saturday 5 November 2011

Java interview questions: - Describe JDBC and steps involved in the JDBC connection.

A widely asked  Java interview questions in most of the Java interview.

So one can start the answer as follows: -

Definition: -


JDBC is a set of Java API for executing SQL statements. This API consists of a set of classes and interfaces to enable programs to write pure Java Database applications

Steps in the JDBC connection: -

Step 1: Register the database driver by using:
Class.forName(\" driver class for that specific database\" );

Step 2: Now create a database connection using:
Connection con = DriverManager.getConnection(url,username,password);

Step 3: Now create a query using:
Statement stmt = Connection.Statement(\"select * from TABLE NAME\");

Step 4: Execute the query:
stmt.exceuteUpdate();

Also see the following video on Java Builder Design Pattern as follows: -



Know more on  Java interview questions

Regards,


Get more on Java interview questions from author’s blog.

Wednesday 2 November 2011

21 important Java/J2EE interview questions

This following part will cover the most asked Java/J2EE interview questions during Java/J2EE interview.

So have a look on the same and do revise it when ever you go for the Java/J2EE interview questions  interview.

Normally the Java’s interviewer starts with.....
  • What is the difference among JVM Spec, JVM Implementation, JVM Runtime?
  • What are JDK and JRE?
  • What is JIT?
  • What is a JVM heap?
  • What is sandbox?
  • What is Locale? 
  • What is a ResourceBundle class?
  • How will you get the platform dependent values like line separator, path separator? 
  • How does garbage collector decide which objects are to be removed? Can garbage collector be forced?
  • What is the final keyword denotes w.r.t class, method and variable?
  • What are the methods in Object? 
  • Can you instantiate the Math class?
  • What is the difference between the instanceof and getclass, these two are same or not?
  • Can main method be declared final? 
  • What is a native method?
  • Does Java provide any construct to find out the size of an object?
  • Is Empty .java file a valid source file?
  • Can a .java file contain more than one java classes?
  • What is the difference between an argument and a parameter?
  • What are the different scopes for Java variables? 
  • What are wrapper classes?
Also see the following video on on FlyWeight Pattern which will help you to boost your interview preparation: -




Get more study materials on Java/J2EE interview questions

Regards,

See for more author’s other blog on Java/J2EE interview questions


Saturday 29 October 2011

Java/J2EE interview questions: - How would you create a thread pool in Java/J2EE??

While facing Java/J2EE interview questions you may come across this question by the interviewer. So you can your start with the answer as follows.

public class ThreadPool implements ThreadPoolInt.

This class is an generic implementation of a thread pool, which takes the following input: -
  • Size of the pool to be constructed.
  • Name of the class which implements Runnable and constructs a thread pool with active threads that are waiting for activation. Once the threads have finished processing they come back and wait once again in the pool.
This thread pool engine can be locked i.e. if some internal operation is performed on the pool then it is preferable that the thread engine be locked. Locking ensures that no new threads are issued by the engine. However, the currently executing threads are allowed to continue till they come back to the passive Pool.

Interested to learn more, then view the following detailed video on Java Builder pattern which is also asked during Java/J2EE interview questions: -



Visit for more Java/J2EE interview questions series.

Regards,

Also visit author’s blog for more Java/J2EE interview questions

Monday 24 October 2011

Java/J2EE interview questions: – Distinguish between State and Strategy pattern .

This is one of the most asked JAVA/J2EE interview questions.

So one can differentiate this design pattern and answer this as follows: -

Strategy
State
Family of algorithms is interchangeable which means that every algorithm does the same thing but in different way.States are not interchangeable.
Encapsulate each algorithm into a class.We encapsulate each state into a class in state pattern.
Descendants should prepared for most possible events.
Can only process a few events according to the state machine model.
Concrete strategies usually don’t know the others.
Usually concrete states know other concrete states.
More dynamic modeling.More static modeling.

Also see the following video on Buider Design Pattern for the preparation of JAVA/J2EE interview questions: -


Visit for Java/J2EE interview questions

Regards,

Visit for more author's other blogs on Java/J2EE interview questions


Monday 17 October 2011

Java/J2EE interview questions: - Is using StringBuffer always yields better performance than concatenation using +?

No, String Buffer need not yield a good performance over String concatenation using "+".

The type of concatenation plays a major role in deciding performance. If the concatenation can be completely resolved at coimpile time then String concatenation using + will yield better results
On the other hand if concatenation is done at run time using StringBuffer is more advisable, since StringBuffer objects are resolved at run time

Following are the two programs one showing compile time resolution and other run time and thus showing where StringBuffer will be useful.

Compile time resolution: 


This program takes String literals and performs concatenation using + as well as StringBuffer. Since the String literals could be resolved at compile time itself, this indicates a case of compile time resolution.


Code is self explanatory with proper comments given where ever required.
On executing the above code we get following result

Result:


Concatenation using + takes 0 millisecs
Concatenation using StringBuffer takes 63 millisecs
Performance using concatenation using + better than StringBuffer concatenation.

Conclusion: Since the above case if of compile time resolution performance using + concatenation yields a better result.

Run Time resolution:


Just a small modification to compile time code shown above can give us run time case for further analysis.

We change the concatenation used above to String conResult =""; conResult = conResult +"Welcome to the World of Java" +"Performance" +"@"+"questpond";

a similar change is done in StringBuffer . code snippet after change will look like





Result :


Concatenation using + takes 47 millisecs
Concatenation using StringBuffer takes 32 millisecs
Performance using concatenation using StringBuffer better than + concatenation.



Conclusion : the above case clearly shows StringBuffer giving more performance as compared to + concatenation at run time.

Overall final conclusion: Prefer StringBuffer whenever run time resolution concatenation is involved
View the following video on J2EE Design Pattern - Service Locator: -



Get more Java/J2EE interview questions

Friday 26 August 2011

Java Design Pattern - Video on Builder Pattern

This video will discuss about the facts on Java Builder Design Pattern.

Java and J2EE Design Pattern - Front Controller

The video will explain one of the J2EE Design Pattern Front Controller pattern.


Java and J2EE Design Pattern - Value List Handler

The video will explain one of the J2EE Design Pattern Value List Handler pattern.


Java and J2EE Design Pattern - Service Locator

After making your selection, copy and paste the embed code above. The code changes based on your selection.

Thursday 25 August 2011

Java interview questions: - What are the difference between Servlet and Restfull web service?

Servlets are API which is simple and provides capabilities to write server side components.

Rest provides higher level support for writing services which are denoted by using the concept of resource which represents a concept to be addressed while representation indicates the current state of resource. Also Rest provides other facilities like seperation of concerns between client and server, uniform interface,stateless,Caching capability and layered architecture.

View the following video on Web services: -



Get more on java interview questions