These questions cover object design, method calls, strings, collections, exceptions, and concurrency. For each answer, explain the rule first, then use the nearby example to show where it matters. The examples are small demonstrations; an application may need more error handling and tests.
1. How Do You Make a Java Class Immutable?
An immutable object has state that cannot change after construction. Make its fields private, establish their values in the constructor, and avoid exposing mutable internals. A final class prevents a subclass from adding a way to change the apparent contract. A final field alone is insufficient if it refers to a mutable object.
final class Appointment {
private final java.time.LocalDate date;
Appointment(java.time.LocalDate date) {
this.date = java.util.Objects.requireNonNull(date);
}
java.time.LocalDate date() { return date; }
}
LocalDate is itself immutable, so returning it is safe. If the field were a mutable list, the constructor and accessor would need defensive copies.
2. Does Java Pass Objects by Reference or by Value?
Java passes a copy of every argument value. For an object argument, that value is a reference. The copied reference can mutate the same object, but assigning it to another object does not reassign the caller’s variable.
class PassByValueDemo {
static void change(StringBuilder value) {
value.append("!");
value = new StringBuilder("other");
}
public static void main(String[] args) {
StringBuilder caller = new StringBuilder("hi");
change(caller);
System.out.println(caller); // hi!
}
}

The diagram shows that the caller and method parameter can refer to the same object. It does not imply that assigning the parameter changes the caller’s variable.
3. When Does a finally Block Run?
It normally runs when control leaves its try or catch, including through a return or exception. It may not run if the process terminates before control leaves. Prefer try-with-resources for an AutoCloseable resource.
static int answer() {
try { return 42; }
finally { System.out.println("cleanup"); }
}
// Calling answer() prints cleanup, then returns 42.
4. How Do java.util.Date and java.sql.Date Differ?
The JDBC type represents an SQL DATE, which has a calendar date but no time of day. The older utility type represents an instant to millisecond precision. For new domain code, prefer LocalDate for a date without time and convert at the JDBC boundary.
java.time.LocalDate due = java.time.LocalDate.of(2030, 4, 15);
java.sql.Date jdbcDate = java.sql.Date.valueOf(due);
System.out.println(jdbcDate.toLocalDate().equals(due)); // true
5. What Is a Marker Interface?
A marker interface has no methods but marks a type as having a particular contract. Serializable is a familiar example. Implementing it signals eligibility for Java serialization; it does not make every referenced field serializable.
final class Receipt implements java.io.Serializable {
private static final long serialVersionUID = 1L;
private final String number = "R-42";
}
6. Why Does the Familiar main() Method Use public static void?
In the familiar launcher form, public makes the method accessible, static lets the launcher call it without an application object, and void means it returns no Java value. Launcher rules can also accept other entry-point forms, so describe the signature you are using instead of claiming it is the only possible one.
public class App {
public static void main(String[] args) {
System.out.println(args.length);
}
}
7. How Does a String Literal Differ from new String(…)?
Equivalent literals resolve to a shared interned String. The constructor makes a distinct object with the same text. Use equals() for text equality.
String literal = "java";
String again = "java";
String copy = new String("java");
System.out.println(literal == again); // true
System.out.println(literal == copy); // false
System.out.println(literal.equals(copy)); // true
8. What Does substring() Return?
substring(begin, end) returns characters from the inclusive begin index to the exclusive end index. These indexes count UTF-16 code units. Do not assume a code-unit boundary is also a user-perceived character boundary.
String ticket = "AB-123";
System.out.println(ticket.substring(3, 6)); // 123
9. How Does HashMap Handle Equal Keys and Collisions?
The map uses a key’s hash to choose a bin, then compares candidate keys by identity or equals(). Equal keys replace the associated value; unequal keys can share a hash and coexist. A hash is not a unique identifier.
java.util.Map<String, Integer> counts = new java.util.HashMap<>();
counts.put("tea", 1);
counts.put(new String("tea"), 2);
System.out.println(counts.size()); // 1
System.out.println(counts.get("tea")); // 2
10. When Should You Use an Interface or an Abstract Class?
An interface defines a capability that otherwise unrelated classes can implement. An abstract class can share state and implementation among closely related subclasses. A class can implement multiple interfaces but extend only one class.
interface Exportable { byte[] export(); }
abstract class Report { final String title; Report(String title) { this.title = title; } }
final class SalesReport extends Report implements Exportable {
SalesReport() { super("Sales"); }
public byte[] export() { return title.getBytes(java.nio.charset.StandardCharsets.UTF_8); }
}
11. When Must equals() and hashCode() Be Overridden Together?
Override them when two distinct objects should count as the same logical value. Equal objects must have equal hash codes. Otherwise a hash-based collection may fail to find a logically equal key.
record CustomerId(String value) {}
class CustomerIdDemo {
public static void main(String[] args) {
java.util.Set<CustomerId> ids = new java.util.HashSet<>();
ids.add(new CustomerId("C-7"));
System.out.println(ids.contains(new CustomerId("C-7"))); // true
}
}
The record supplies consistent value-based equals() and hashCode() implementations.
12. What Is the Difference Between a Shallow and Deep Copy?
A shallow copy creates another outer object while sharing referenced mutable objects. A deep copy also copies the mutable objects it needs to isolate. The correct depth depends on the ownership contract.
Original order ---> shared mutable list <--- Shallow copy
Original order ---> original list
Deep copy ---> independent list with copied mutable elements
List.copyOf() copies the list structure but does not deep-copy mutable elements.
13. What Is the Difference Between an Object Lock and a Class Lock?
An instance synchronized method locks that instance. A static synchronized method locks the Class object. Two different instances do not block each other’s instance methods merely because they have the same class.
class Counter {
private int value;
synchronized void increment() { value++; } // locks this Counter
static synchronized void resetGlobal() {} // locks Counter.class
}
14. How Do sleep() and wait() Differ?
Thread.sleep() pauses the current thread for at least the requested time and does not release a monitor it holds. Object.wait() must run while holding that object’s monitor; it releases the monitor and waits for notification, interruption, or a timeout. Always recheck the condition after waking.
java.util.Queue<Object> queue = new java.util.ArrayDeque<>();
// A producer adds items and calls queue.notifyAll() under the same monitor.
synchronized (queue) {
while (queue.isEmpty()) {
queue.wait();
}
Object item = queue.remove();
}
Here queue is a shared queue guarded by its own monitor. A production application usually uses a blocking queue instead of hand-written wait/notify code.
15. Can this Be Assigned null?
No. this is an expression referring to the current object, not an assignable variable. The compiler rejects the assignment.
class Example {
void invalid() {
// this = null; // compile-time error: variable expected
}
}
16. How Do && and & Differ for Boolean Operands?
Both calculate Boolean AND. && skips the right operand when the left is false; & evaluates both. For integer operands, & is bitwise AND.
int[] values = {};
boolean safe = values.length > 0 && values[0] > 0; // false, no lookup
// values.length > 0 & values[0] > 0 would throw.
17. What Can Each Java Access Modifier Expose?
private limits access to the enclosing class; no modifier gives package access; protected adds access for subclasses subject to Java’s protected-access rules; public exposes a member wherever its declaring type is accessible.
private -> declaring class
package-private -> same package
protected -> same package + permitted subclass access
public -> wherever the containing type is accessible
Top-level classes can be public or package-private, not private or protected.
18. Can You Force Garbage Collection?
No. The runtime decides when to collect unreachable objects. System.gc() requests consideration; it does not guarantee a collection or immediate reclamation. Close files and sockets explicitly rather than waiting for collection.
java.nio.file.Path path = java.nio.file.Path.of("receipt.txt");
try (java.io.InputStream in = java.nio.file.Files.newInputStream(path)) {
System.out.println(in.read());
} // close() runs here, independent of garbage collection
The file must exist and be readable. The point of the example is the guaranteed close() call, not the file contents.
19. What Does the native Modifier Mean?
A native method declares an implementation outside Java. Calling it requires a compatible native library to be loaded. It does not make a method inherently faster or safer.
class DeviceDriver {
native int readRegister(int address);
// A compatible loaded native library must provide this implementation.
}
20. What Should You Watch for in Java Serialization?
Java object serialization writes and reconstructs object graphs under Serializable. It is a compatibility mechanism, not a safe format for arbitrary untrusted input. Do not deserialize bytes from an untrusted source without strict filtering and a deliberate format decision.
record InvoiceId(String value) implements java.io.Serializable {}
// Prefer an explicit JSON or other data format at an external API boundary.
21. Can a HashMap Be Shared Across Threads?
Concurrent reads can be safe when the fully built map is safely published and no thread changes it. Concurrent mutation requires synchronization or a suitable concurrent map. For an atomic count update, use ConcurrentHashMap.merge().
java.util.concurrent.ConcurrentHashMap<String, Integer> counts = new java.util.concurrent.ConcurrentHashMap<>();
counts.merge("tea", 1, Integer::sum);
22. How Do Abstraction and Encapsulation Differ?
Abstraction presents the operations a client needs. Encapsulation controls access to an object’s internal state and preserves its rules. An interface can provide abstraction; a private field with guarded methods provides encapsulation.
interface Account { void deposit(long cents); }
final class SavingsAccount implements Account {
private long balance;
public void deposit(long cents) {
if (cents <= 0) throw new IllegalArgumentException();
balance += cents;
}
}
23. When Does StringBuffer Save Allocations?
Repeated String concatenation in a loop can create intermediate strings. A mutable builder accumulates characters in an expandable buffer. Use StringBuilder for local construction; choose StringBuffer when its synchronized methods are specifically needed.
StringBuilder line = new StringBuilder();
for (String part : java.util.List.of("A", "B", "C")) line.append(part);
System.out.println(line); // ABC
24. Why Are wait() and notify() Methods on Object?
Waiting and notification coordinate on a particular object’s monitor. Any object can act as that monitor, so these operations belong to Object. Calling them without owning that monitor throws IllegalMonitorStateException.
Object signal = new Object();
synchronized (signal) {
signal.notifyAll(); // valid because this thread owns signal's monitor
}
25. How Can You Create and Prevent a Deadlock?
A deadlock can occur when two threads acquire the same locks in opposite orders. In this demonstration, a latch makes each thread hold its first lock before either asks for the second. The threads are daemon threads so the demonstration process can finish after detecting the deadlock.
import java.lang.management.ManagementFactory;
import java.util.concurrent.CountDownLatch;
public class DeadlockInterviewDemo {
static void lockInOrder(Object first, Object second) {
synchronized (first) {
synchronized (second) { /* work with both resources */ }
}
}
static void lockInOppositeOrder(Object first, Object second, CountDownLatch bothHoldingFirst) {
synchronized (first) {
bothHoldingFirst.countDown();
try {
bothHoldingFirst.await();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return;
}
synchronized (second) { /* cannot be reached by both threads */ }
}
}
public static void main(String[] args) throws InterruptedException {
Object x = new Object();
Object y = new Object();
CountDownLatch bothHoldingFirst = new CountDownLatch(2);
Thread a = new Thread(() -> lockInOppositeOrder(x, y, bothHoldingFirst));
Thread b = new Thread(() -> lockInOppositeOrder(y, x, bothHoldingFirst));
a.setDaemon(true);
b.setDaemon(true);
a.start();
b.start();
bothHoldingFirst.await();
long deadline = System.nanoTime() + 2_000_000_000L;
long[] deadlocked = null;
while (deadlocked == null && System.nanoTime() < deadline) {
deadlocked = ManagementFactory.getThreadMXBean().findMonitorDeadlockedThreads();
if (deadlocked == null) Thread.sleep(10);
}
System.out.println("deadlock detected: " + (deadlocked != null));
Object orderedX = new Object();
Object orderedY = new Object();
Thread c = new Thread(() -> lockInOrder(orderedX, orderedY));
Thread d = new Thread(() -> lockInOrder(orderedX, orderedY));
c.start();
d.start();
c.join(1_000);
d.join(1_000);
System.out.println("ordered threads finished: " + (!c.isAlive() && !d.isAlive()));
}
}
The first pair holds x and y in opposite orders, so neither can acquire the second monitor. The management bean detects that cycle. The second pair uses separate locks and acquires both in the same order. Both finish. Running the file prints deadlock detected: true and ordered threads finished: true. In application code, define and document one lock order wherever more than one monitor may be held.
26. How Do transient and volatile Differ?
transient excludes a field from default Java serialization. volatile gives reads and writes of a field visibility and ordering guarantees between threads; it does not make a compound increment atomic. The modifiers solve different problems.
class Job implements java.io.Serializable {
transient String cachedDisplayName;
volatile boolean cancelled;
}
The cached name can be rebuilt after deserialization. A worker can observe a cancellation write from another thread when it reads cancelled.
For deeper API details, see the Java language specification, String API, HashMap API, and concurrent collections package.
Happy Learning!
Hi Lokesh,
Can you update this page for the below question.
Difference between interfaces and abstract classes?
“A Java abstract class can have the usual flavors of class members like private, abstract.”
There is no use of declaring the abstract class method as private and only you can declare data members as private.
Please check once
Thanks for the information.
There is comma between private and abstract for this reason. Anyway, I updated the text so it does not create this confusion to others. Thanks for your comment.
Superb content. thanks to Lokesh for share valuable information to with us.
This is the best material i have ever read about java in my entire 4 years of career. I feel so fortunate that i got this sort of straight to the point explanation for my revision.
I am glad you find it useful.
Thanks,
beautiful article
very helpful and useful list of core java interview question will be good to prepare for interview. I have an interview next week as java developer and i can predict what they will ask or what type of question will ask from this list. Thanks a lot!
You have some problems with English
I also realize it. And I am working on it. Thanks for the feedback. Much appreciated.
I beg to differ on the point where you say in question
What is the difference between creating String as new() and literal?
“When we create String with new() it’s created in heap and also added into string pool” The thing is when I create a String object using new only one object is created in the Heap and is still not placed in the String Pool. In order to place it in the String Pool, you need to call String.Intern() method on it. this will put the String the String Pool.
Hi Tushar, I must say it’s some how confusing for me too – till date. Let me put my logic:
Here, we both agree that one new object will be created in heap – so let’s leave that discussion. Coming to main point, the argument
"abc"is a string literal and before passing it to String class’s constructor, JVM must somehow interpret it and that is done by placing it inside string pool.Your logic??
This is from Java Doc-
public String intern()
Returns a canonical representation for the string object.
A pool of strings, initially empty, is maintained privately by the class String.
When the intern method is invoked, if the pool already contains a string equal to this String object as determined by the equals(Object) method, then the string from the pool is returned. Otherwise, this String object is added to the pool and a reference to this String object is returned.
It follows that for any two strings s and t, s.intern() == t.intern() is true if and only if s.equals(t) is true.
Returns:
a string that has the same contents as this string, but is guaranteed to be from a pool of unique strings.
Here they didn’t mention anything about Heap
Explain the working of HashMap. How duplicate collision is resolved?
while iterating over LinkedList on calculated index, HashMap calls equals() method on key object for each Entry object…
Just to add one more imp thing here i.e. after rehashing the key the new hascode is saved in the Entry object together with key and value. While iterating over linkedlist, Hashmap together with reference equality and object equality it also check for the hashcode match too.
if(e.hash == hash && ((k = e.key) == key || key.equals(k))){...}Please refer: https://howtodoinjava.com/java/collections/hashmap/how-hashmap-works-in-java/
What is the use of the finally block? Is finally block in Java guaranteed to be called? When finally block is NOT called?
if the thread executing the try or catch code is interrupted…
I wrote a test for the above case but unable to reproduce. Could you highlight when this is possible.
Test Code
package core.thread.interrupt; public class InterruptThread implements Runnable { @Override public void run() { try { Thread.sleep(10000); } catch (InterruptedException intException) { intException.printStackTrace(); } finally { System.out.println("finally executed"); } } } package core.thread.interrupt; public class InterruptThreadMain { public static void main(String...args) { Thread thread = new Thread(new InterruptThread()); thread.start(); thread.interrupt(); } } o/p : java.lang.InterruptedException: sleep interrupted finally executed and the stack frame dumpYou may use the method
setDaemon(boolean status)which is used to mark the current thread as daemon thread or user thread and exit the JVM as and when required. This will enable you exit the JVM beforefinally{}is executed.public class InterruptThreadMain { public static void main(String...args) throws InterruptedException { Thread thread = new Thread(new InterruptThread()); thread.setDaemon(true); thread.start(); //Let the thread start - at least Thread.sleep(1000); thread.interrupt(); } } class InterruptThread implements Runnable { @Override public void run() { try { System.out.println("Thread Start"); Thread.sleep(10000); } catch (InterruptedException intException) { intException.printStackTrace(); } finally { System.out.println("finally executed"); } } } Output: Thread StartHi Lokesh,
When I executed the above snippet as you have mentioned here, the output is something else. The finally block is getting executed.
Hi Lokesh
Greetings!!!
What is the internal functionality of below code?
String strObj = new String(null); – Exception at Compile time
StringBuilder d = new StringBuilder(null); – Exception at Runtime
Please clarify.
Hi Lokesh,
Why the Singleton classes are in JVM level not in application level? Please clarify.
This is tricky question. Usually when we talk about singleton, we assume that only one instance of application is running in one JVM. A singleton is always tied to classloader hirarchy for application. In case of single instance of application running on JVM, there can be only one class loaded by classloaders.
What if we deploy two instances of same application in same JVM/server instance? Here the location of singleton class will decide the number of instances created for singleton class. E.g. if class belongs to any shared lib (any j2se class or tomcat lib class) then both applications ( sharing same parent class loader for java and tomcat ) will have only one singleton instance. BUT, if class belongs to application specific lib folder, then both application will end up having their separate instances of same singleton because classloader for both application is separate.
You can find more detailed discussion of StackOverFlow thread1 and thread2.
Thanks Lokesh. Can you please explain Abstraction with some real time example?
Hi Lokesh
import java.io.*; import java.util.*; public class HelloWorld { public static void main(String []args) throws IOException,ClassNotFoundException { ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("Newfile.txt")); out.writeObject(new Child()); ObjectInputStream in = new ObjectInputStream(new FileInputStream("Newfile.txt")); System.out.print(in.readObject()); System.out.println(); } } class Parent { protected transient String hello = "Hello!"; } class Child extends Parent implements Serializable{ int age = 11; public String toString() { return "age="+age+" hello="+hello; } }Actual Result of above snippet : age=11 hello=Hello!
My doubt is, hello string should print null because it is declared as transient. How come the value got serialized?
Please clarify.
I slightly modified your code to make it more clear:
import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; public class HelloWorld { public static void main(String []args) throws IOException,ClassNotFoundException { ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("Newfile.txt")); out.writeObject(new Child()); out.close(); ObjectInputStream in = new ObjectInputStream(new FileInputStream("Newfile.txt")); Child c = (Child)in.readObject(); in.close(); //parent System.out.println(c.hello); //child System.out.println(c.age); System.out.println(c.world); } } class Parent { protected transient String hello = "Hello!"; } class Child extends Parent implements Serializable{ int age = 11; protected transient String world = "World"; public String toString() { return "age="+age+" hello="+hello+" world="+world; } }As per java docs:
So essentially, only
Childclass is part of serialization and de-serialization.Parentclass is created by calling it’s default constructor and normal initialization process, so value is set forhellofield.Effect of serialization is visible in new
transientfield added inChildclass.Thanks Lokesh. So, there will not be any impact by using transient declaration in non-serializable classes. Right?
Yes, in relation to serialization.
Excellent work. Please keep it up.. :)
Hi Lokesh,
The memory leak with string that you mentioned here have been fixed in 1.7 right ?
Yes.
Thank you Lokesh! Important, clear and helpful questions!
Hi,
This is great website which explain most critical topics in detail, I love the way you explained HashMap and HashSet concept, waiting for your book in market for Java details interview preparation for experience candidate, because in so many websites they just highlighted the concept but you explained them really well.
wish you all the best.
Regards,
Raj Sharma
Hi Lokesh,
Excellent website. I always come back here to brush up my knowledge.
One doubt from a question on this page.
For the question “Why main() in java is declared as public static void?”, you say that irrespective of the access modifiers, java.exe or javac.exe can invoke the main method. But, when I try to run a test program which does not have ‘public’ access modifier for main(), it gives me the below error. Has the behavior changed lately?
Error: Main method not found in class TestJavaMain, please define the main method as:
public static void main(String[] args)
Bastin, java.exe file is written in native code and uses C++ like instructions to verify the syntax and execute
main()method. Infact, error “does not have ‘public’ access modifier” is itself thrown from inside java.exe file sourcecode, when syntax does not match.But, I get this error when running the program from command line using java.exe. If it doesn’t have such a restriction, then it should work fine.
Hi Lokesh,
Well explained theoritically.
If you provide programs for each concept will be more easier to understand the internals of java.
Please do it.
Why can’t you provide with examples
thanks this helped lot.
Hi Lokesh,
One of the interview, they asked me how to do sort in ascending order on String of characters after converting them into Ascii values and I answered in below mentioned way but he does not satisfied with my answer.Could you please tell me other way to do this.
I have coded like this.
public static String convert_String_To_Ascii(String numStr){
char ch[] = numStr.toCharArray();
int first=0;
int last=0;
StringBuffer asn=new StringBuffer();
for(int i=0;i<ch.length;i++)
{
first=(int) ch[i];
for(int j=i;jlast)
{
char temp=(char)first;
first=last;
ch[i]=(char)last;
ch[j]=temp;
}
}
}
return new String(ch);
}
What about below?
String s = “some-string-here”;
byte[] bytes = s.getBytes(“US-ASCII”);
Arrays.sort(bytes);
It’s sort and easy to read. Your’s is also correct.
Veri Nice Post.
In this page you mentioned:
When we create string with new () it’s created in heap and not added into string pool
and in https://howtodoinjava.com/interview-questions/string-questions/ you have mentioned:
==================================
2) Using new keyword
String str = new String(“abc”);
This version end up creating two objects in memory. One object in string pool having char sequence “abc” and second in heap memory referred by variable str and having same char sequence as “abc”.
==================================
Isn’t it contradictory to each other?
Hey Sumeet, Good catch. It was a typo (sometimes happen when you type so much text). Thanks for pointing out and I have corrected that.
To put more focus on topic, When you use new keyword and pass a String parameter then that parameter is actually a String literal and string literal in string pool gets created even before your String() constructor is called. So, on runtime when constructor is called, you get your second object in heap area.
“Compile-time constant expressions of type String are always “interned” so as to share unique instances, using the method String.intern”
Source: https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.28
Hi, thank you for your post, very nice!
At the question: “Why there are two Date classes; one in java.util package and another in java.sql?”
When you say : “So, what changed in java.sql.Date: […] the getters and setter for hours, minutes and seconds are deprecated” I feel it’s a bit misleading, because in the original java.util.Date class, those methods are already deprecated, but it’s just not for the same reasons.
https://docs.oracle.com/javase/7/docs/api/index.html?java/util/Date.html
You caught me on wrong foot.- :-) OK, it can be misleading. So let’s me clarify again.
Methods in java.util.Date were gone deprecated because of Calendar class was considered recommended approach. So, util’s Date class’s multiple methods were marked as deprecated.
e.g. setMinutes(int minutes) :: Deprecated. As of JDK version 1.1, replaced by Calendar.set(Calendar.MINUTE, int minutes).
But, in java.sql.Date class it was deprecated because they are (though not enforced) conceptually discouraged.
e.g. setMinutes(int i) :: Deprecated. This method is deprecated and should not be used because SQL Date values do not have a time component.
I like this answer ;) Thx!
Great list dude. Keep it up the writing.
public class FinallyReturnVariableAlter
{
public static void main(String[] args)
{
System.out.println(test());
}
public static int test()
{
int i=0;
try
{
return i;
}
finally
{
i+=100;
}
}
}
why the return value is 0 instead of 100?
Manohar, This is really good question and most fail to answer it correctly. Let me put my reasoning.
Every function call in java leads to creation of extra memory space created where return value is stored for reference after function execution completes and execution return to caller function back.
At that time, that special memory address where return value is stored, if referenced back as return value of function.
Here, trick is, the memory slot store the value of returned value, not its reference. So, once any return statement is encountered its value is copied in memory slot. That’s why if you change the value of “i” in finally, return value does not change because its already copied to memory slot.
We any other return statement is encountered (e.g. in finally block), its value will be overwritten again. So, it you want to return 100, use return statement in finally also.;
Hi Lokesh,
does the finally block executes if we have a return statement in try block if it works fine without throwing an exception?
Yes.
whatever you return in try block will be override by finally block if you are returning anything in finally block.
Hi Lokesh
certainly I will go thr’ questions but tell me java code to connect to
hsqldb .I am getting user lacks privilege or object not found: EMPLOYEEDETAILS exception
pl help me
Are you using hibernate.. match your properties..
https://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html_single/#d5e54