Friday 27 January 2012

Java interview questions: - Explain different types of inner classes?

Following are the different types of inner classes in  Java interview questions.

Nested top-level classes-
  • If you declare a class within a class and specify the static modifier, the compiler treats the class just like any other top-level class
  • Any class outside the declaring class accesses the nested class with the declaring class name acting similarly to a package. eg, outer. Inner
  • Top-level inner classes implicitly have access only to static variables. There can also be inner interfaces. All of these are of the nested top-level variety.
Member classes -
  • Member inner classes are just like other member methods and member variables and access to the member class is restricted, just like methods and variables.
  • This means a public member class acts similarly to a nested top-level class
  • The primary difference between member classes and nested top-level classes is that member classes have access to the specific instance of the enclosing class.
Local classes-
  • Local classes are like local variables, specific to a block of code. Their visibility is only within the block of their declaration. In order for the class to be useful beyond the declaration block, it would need to implement a more publicly available interface.
  • Because local classes are not members, the modifiers public, protected, private, and static are not usable.
Anonymous classes-
  • Anonymous inner classes extend local inner classes one level further. As anonymous classes have no name, you cannot provide a constructor
  • Anonymous class is a class defined inside a method without a name and is instantiated and declared in the same place and cannot have explicit constructors
See the following video on Java - Introduction to Hibernate and it concepts: -



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.

Saturday 21 January 2012

Java interview questions: - Different types of rowset in java 5?

This is one of the typical Java interview questions asked by the interviewer during the interview session. So one can proceed answering it as follows: -

JdbcRowSet:
  • A wrapper around a ResultSet object that makes it possible to use the result set as a JavaBeans component
  • By default all result set are scrollable and updatable
CachedRowSet
  • object is a container for rows of data that caches its rows in memory, which makes it possible to operate without always being connected to its data source
  • Further, it is a JavaBeans component and is scrollable, updatable, and serializable
FilteredRowSet
  • Provides a degree of filtering on contents without heavy weight query language
  • Extends CacheRowSet and overrides methods for filtering
JoinRowSet
  • Provides a mechanism for combining related data from different RowSet objects into one JoinRowSet object, which represents an SQL JOIN
  • can take one of the following to denote type of join
  1. CROSS_JOIN
  2. FULL_JOIN
  3. INNER_JOIN - the default if no JOIN type has been set
  4. LEFT_OUTER_JOIN
  5. RIGHT_OUTER_JOIN
WebRowSet

It describes the standard XML document format required when describing a RowSet object in XML

SyncResolver

Is a rowset object wgich implement SyncResolver interface which allows applications to use a manual decision tree to decide what should be done when a synchronization conflict occur

Also see video on Many To One relation in database using Hibernate as follows: -



Click for more Java interview questions

Regards,

Visit for more author’s blog on Java interview questions.

Wednesday 18 January 2012

Java interview questions: – 20 Basic Interview questions on Java? Part: -3.

  • What is Upper bounded wildcards in generics?
  • What is JAR file?
  • What are different types of inner classes?
  • Can we declare an anonymous class as both extending a class and implementing an interface?
  • What is the difference between a static and a non-static inner class?
  • How does Java handle integer overflows and underflows?
  • Does garbage collection guarantee that a program will not run out of memory?
  • What is the purpose of finalization?
  • Can an unreachable object become reachable again?
  • What is a reflection package?
  • What do you mean by immutable? How to create an immutable object?
  • What is class loader in java?
  • What is a weak reference?
  • What is object cloning?
  • What is object pooling?
  • What are marker interface /tag interface?
  • What is the difference between Comparable and Comparator?
  • Does a class inherit the constructors of its superclass?
  • What are annotations used for?
  • What are the annotations used by compiler?
View the following video on Hibernate and it concept in Java: -



For more on Java interview questions so click and visit.

Regards,

Author’s more on Java interview questions


Friday 13 January 2012

JAVA INTERVIEW QUESTIONS: - 20 BASICS INTERVIEW QUESTIONS ON JAVA? Part: -2.

  • 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 is UNICODE?
  • What are Transient and Volatile Modifiers?
  • What are the different scopes for Java variables?
  • What are wrapper classes?
  • What is a the difference between System.err and System.out?
  • What are the contracts defined by .equals()?
  • If two objects are considered equal by .equals() , can it be said they has same hashCode()?
  • If two objects have same hashCode() is it necessary they will be equal by using .equals() method?
  • What contracts hashCode () defines?
  • What is the difference between == and equals?
  • What is the difference between List and List (not parameterized list and list parameterized by String) in Java?
  • What are generics in jdk1.5?
  • Are generics covariant?
  • What are Lower-bounded wildcards in generics?
  • What is Upper bounded wildcards in generics?
View the following video on Inheritance between beans and Spring in Java: -



For more on  Java interview questions so click and visit.

Regards,

Author’s more on Java interview questions

Tuesday 10 January 2012

Java Interview Questions: - 25 Basics interview questions on Java?

  • What if the main method is declared as private?
  • What if the static modifier is removed from the signature of the main method?
  • Can we define private and protected modifiers for variables in interfaces?
  • Can there be an abstract class with no abstract methods in it?
  • What modifiers are allowed for methods in an Interface?
  • What is a local, member and a class variable?
  • What does it mean that a method or field is “static”?
  • Is null a keyword?
  • What modifiers may be used with an inner class that is a member of an outer class?
  • What is class path?
  • What is path?
  • 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, etc?
  • 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 get class, these two are same or not?
  • Can main method be declared final?
View the following video on Batch Processing in Java: -



For more on  Java interview questions so click and visit.

Regards,

Author’s more on Java interview questions


Friday 6 January 2012

Java Interviews questions: -How can you explain views and its type?

A view can be thought of as either a virtual table or a stored query is a database object that is a logical representation of a table Views are mainly classified as

Simple view:
  • is created by selecting only one table
  • does not contains functions.
  • can perform operations through simple view
Complex view :
  • It is created by selecting more than one table.
  • It can performs functions.
  • can not perform always DML operations
Also see the following interesting video on Java - Inheritance between beans and Spring : -



Know more on Java interview questions

Regards,

Get more on Java interview questions from author’s blog