Showing posts with label JVM. Show all posts
Showing posts with label JVM. Show all posts

Wednesday, 28 March 2012

Java interview questions: - Explain Native Interface in JAVA?

JNI is a mechanism by which you can invoke method written in native language like C and C++. Native languages allow you to use a platform specific feature which is not in control of java language. For instance if you want java to interact directly with some specific type of hardware it will extremely difficult to achieve it. So you can write a C code and declare its native methods and call the same in Java.


Figure: - JNI in action


The above figure indicates how JVM interacts with JNI and without. With JNI it has the extra layer of C or C++ DLL i.e. native source code or native methods which interacts with the operating system.

See the following video on Batch Processing in Hibernate: -



Click for more Java interview questions

Regards,

Visit for more author’s blog on Java interview questions

Tuesday, 24 January 2012

Java/J2EE interview questions: - Define singleton in a clustered environment?

In clustering there are multiple J2EE containers running on multiple JVM'S as a Result maintaining singleton is possible with following steps

1) RMI singleton object is created on only one container

2) Stubs of the same are registered in the cluster by adding the same in JNDI Name tree, thus making itself available to entire cluster

The disadvantage of the above approach as follows:

1) In case the singleton has not been created then the container created one Adds the same to JNDI. If 2 container creates singletons simultaneously then there will be a problem

2) The above problem can be solved by delegating the responsibility of creating the singleton to a single container but will cause problem in case the container in consideration fails

Also see the following video on Java and J2EE Design Pattern - Value List Handler: -



Click for more Java/J2EE Design Pattern Interview questions.

Regards,

Visit for more author’s blog on Java /J2EE Design Pattern Interview questions.