0% found this document useful (0 votes)
1 views1 page

Java Notes

The document covers key Java concepts including OOP principles, JVM memory management, string handling, and exception handling. It explains inheritance, static vs non-static methods, the immutability of strings, and the importance of overriding equals() and hashCode() for hash structures. Additionally, it outlines exception types and handling mechanisms using try-catch-finally blocks.

Uploaded by

Arshita Marwaha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views1 page

Java Notes

The document covers key Java concepts including OOP principles, JVM memory management, string handling, and exception handling. It explains inheritance, static vs non-static methods, the immutability of strings, and the importance of overriding equals() and hashCode() for hash structures. Additionally, it outlines exception types and handling mechanisms using try-catch-finally blocks.

Uploaded by

Arshita Marwaha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Interview Notes (Up to Exception Handling)

OOP Concepts

Inheritance allows child classes to extend parent behavior. Overriding requires same signature and
allows covariant return types.

Static methods belong to class (compile-time binding), non-static methods use runtime
polymorphism.

Final keyword: variables can't change, methods can't be overridden, classes can't be extended.

JVM and Memory

Java code is compiled into bytecode (.class) which JVM executes.

Heap stores objects, Stack stores references and method calls.

Class loading happens dynamically when needed.

Strings

Strings are immutable. String Constant Pool (SCP) avoids duplicates.

new String() creates object in heap; literals go to SCP.

StringBuilder is fast and non-thread-safe; StringBuffer is thread-safe but slower.

equals() and hashCode()

equals() compares values, hashCode() determines bucket location in hash structures.

If equals() is true, hashCode must be same.

Both must be overridden together for correct HashMap/HashSet behavior.

Exception Handling

Exceptions disrupt program flow. Checked exceptions are compile-time, runtime exceptions occur
during execution.

try-catch-finally is used for handling. finally always executes unless JVM exits.

throw is used to explicitly throw exceptions; throws declares them.

finally with return overrides try return.

You might also like