2 min read
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
- Primitive Data Types
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
- Compile Time
- Method Overriding/Dynamic Polymorphism
- Run-Time
- Method Overloading/Static Polymorphism
- Is-a Relationship is basically Inheritance
- Ex: Dog is-a Animal
- 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
- Aggregation
- 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):
0000 0011→1111 1100
- Step 2 - Add 1 to the 1’s Complement:
1111 1100+0000 0001=1111 1101
- Result:
1111 1101is the 2’s complement representation of -3 - Verification: In Java,
byte b = -3;internally stores1111 1101
- Binary representation of +3 (8-bit):
- 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
floatordoublefor industry dealing money/currency- Use
BigDecimal
- Use
Confusions
- Difference of two float values can be different than expected.
- 0.3f - 0.1f gives 0.20000002
- Use
BigDecimalfor better and precision calculation