2026-01-04
Topics Studied
- OOPS Fundamentals in Java
- Overview of OOPS
- Objects and Classes
- Pillars of OOPS (Just definitions)
- Data Abstraction
- Encapsulation
- Inheritance
- Polymorphism
- Is-a & Has-a Relationships
- Java Basic Overview
- JDK, JRE, JVM
- Execution Phase
- First Java Program
- Variables
My Understanding
- Data Abstraction is achieved through Interface and Abstract Classes
- Data Encapsulation (DATA-HIDING) achieved by:
- Declare variable of a Class as private
- Provide a public getters and setters to view and modify the value of the variables.
- Multiple Inheritance is not possible in Java
- It is achieved by Interfaces in java by a special functionality override.
- Polymorphism is of two types:
- Method Overloading/Static Polymorphism
- Method Overriding/Dynamic Polymorphism
- Is-a Relationship is basically Inheritance
- Has-a relationship -> whenever an object is used inside other class
- Association is relationship between two different objects.
- Aggregation
- Both objects, can survive individually means ending of one object will not end other object.
- Ex: School and Student
- Composition
- Ending of one object will end other object
- Ex- School and Room
- Java Agents are loaded before the
main() method executes.
- Negative numbers are 2s Compliment of Positive
- Ex: -3 is 2s Compliment of +3
- Step-by-Step: 2’s Complement of 3 (to get -3)
- Binary representation of +3 (8-bit):
0000 0011
- Step 1 - Find 1’s Complement (invert all bits):
- Step 2 - Add 1 to the 1’s Complement:
1111 1100 + 0000 0001 = 1111 1101
- Result:
1111 1101 is the 2’s complement representation of -3
- Verification: In Java,
byte b = -3; internally stores 1111 1101
- Binary Verification: 3 + (-3) = 0
```
0000 0011 (+3)
- 1111 1101 (-3)
———–
1 0000 0000 (9 bits)
```
- The leftmost bit (carry bit) overflows and is discarded in 8-bit arithmetic
- Final result:
0000 0000 = 0 ✅
- This proves the 2’s complement representation is correct!
- Never use
float or double for industry dealing money/currency
Confusions
- Difference of two float values can be different than expected.
- 0.3f - 0.1f gives 0.20000002
- Use
BigDecimal for better and precision calculation
Interview Notes