0% found this document useful (0 votes)
2 views2 pages

Java Detailed Notes

The document provides detailed notes on Java concepts including OOP, inheritance, JVM memory management, strings, and exception handling. It explains key features such as method overriding, the immutability of strings, and the importance of equals() and hashCode() methods. Additionally, it covers exception types and handling mechanisms like try-catch-finally and the use of throw and throws keywords.

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)
2 views2 pages

Java Detailed Notes

The document provides detailed notes on Java concepts including OOP, inheritance, JVM memory management, strings, and exception handling. It explains key features such as method overriding, the immutability of strings, and the importance of equals() and hashCode() methods. Additionally, it covers exception types and handling mechanisms like try-catch-finally and the use of throw and throws keywords.

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 Detailed Notes (Up to Exception

Handling)

OOP & Inheritance

Inheritance allows a child class to acquire properties of a parent class. Method overriding requires
same name and parameters with optional covariant return type.

Static methods belong to class and are resolved at compile time (method hiding). Non-static
methods use runtime polymorphism.

Final keyword: final variable cannot be reassigned, final method cannot be overridden, final class
cannot be extended.

JVM & Memory

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

Heap: stores objects. Stack: stores method calls and references.

Class loading is lazy (on demand), not all classes loaded at once.

Strings

Strings are immutable. Stored in String Constant Pool (SCP).


String s1 = "hello";
String s2 = "hello"; // same reference

new String() creates a new object in heap.

StringBuilder: mutable, fast, not thread-safe.

StringBuffer: mutable, thread-safe, slower.

equals() and hashCode()

equals() compares logical equality. hashCode() determines bucket location.

Contract: if equals() is true, hashCode() must be same.

Used in HashMap/HashSet for lookup.

Exception Handling

Exceptions disrupt normal flow. Types: Checked and Runtime.

try-catch-finally handles exceptions. finally always executes (except JVM termination).

throw is used to explicitly throw exception. throws declares exception.


finally with return overrides try return.

You might also like