Expert Tips for Nailing Your Java and Hibernate Job Interview

What is callable in Java? How different is it from Runnable? 


The callable interface is similar to the runnable interface in that both are intended for classes whose instances may be executed by another thread. 

However, a runnable does not return a result and cannot throw a checked exception.



public interface CallableV>

A task that produces a result and has the potential to throw an exception. Call(), a single method with no arguments, is defined by implementers.

Method Detail:

Only one method is available, i.e., call() throws an exception if it is unable to do so; otherwise, it returns the computed result.

Keep an eye on this site for additional updates, and for Java, visit my GitHub page and learn on your own.


 
Hibernate Entity Life Cycle States or Types of Object States
 
Persistence class objects can be found in any of four different states, or "persistence states.
  1. Transient state
  2. Persistent state
  3. Detached state
  4. Removed state

Transient state

When a persistence class object is newly created (exists in heap memory like a normal Java object) and has not participated in any session operations. 
Then that object is called a "transient object. Hibernate does not maintain or manage entities.

The state of that object is called the "transient state," and the object does not contain any primary key or identity.

Persistent State

When a persistence class object participates in session operations, that object is called a persistence object. 
Persistent entities exist in the database, so hibernate manages the persistent objects.

The state of that object is called the persistence state, and that object contains an identity or primary key.


Note: 
Any modification made to the persistence object will be reflected in the database.
 
Also Checkout this top picks:

Detached State

When a persistence class object participates in session operations and is removed from the session cache, that object is called a detached object.
Detached objects exist in the database but are not maintained by Hibernate.

The state of that object is called the detached state, and the object contains an identity or primary key.

A detached entity can be created by closing the session associated with it or by calling the evict() method.

Removed State

When the persistence class object is removed from the database that is being managed by Hibernate, those objects are called "removed objects. 

And we have to pass the remove() method to the session, and the state of that object is called the removed state.

Interview Questions:

  • There are many ways to create a thread, and which is the best option to create a thread and explain it with a scenario?
  • When we trigger the Java command, how many threads are going to be created? explain it?
  • How do I change the main thread priority? What are min, norm, and max priority?
  • Explain wait(), notify(), and notifyAll()?
  • How does multithreading work? What is the purpose of multithreading?

Conclusion

In this article, we've learned what is callable and how it is different from the runnable interface and Hibernate life cycle states.
Chandra Sekhar

A Blogger and Author! This post was written and edited by me, a technologist. I started this site to share my inspirations, work, and free materials, which I hope others may find useful as well. Man with a creative streak who enjoys experimenting with various web design strategies.

Previous Post Next Post

Microservice Communication in a Distributed System