Java Day 18: Autoboxing, Abstract Classes & POJO

Day 18 of Learning Java Continuing my Java journey! On Day 18, I learned about: ✅ Autoboxing & Unboxing ✅ Abstract Classes (Rules & Concepts) ✅ POJO Classes ✅ Why only one public class per Java file 🔹 Autoboxing & Unboxing Autoboxing: Automatic conversion of primitive → Wrapper class Example: int a = 10; Integer obj = a; Unboxing: Wrapper class → primitive Example: Integer obj = 20; int a = obj; 🔹 Abstract Class (Important Points) • Cannot be instantiated directly • Can contain abstract methods (no body) • Can also contain normal methods • Can have constructors • Can have static methods and variables 🔹 POJO (Plain Old Java Object) A simple Java class that contains: • Private variables • Getter & Setter methods • Constructors Used mainly for data representation. 🔹 Why Only One Public Class Per Java File? Java allows only one public class per file to avoid ambiguity during compilation. The file name must match the public class name because the Java compiler uses that name to locate and compile the class. Example: public class Demo { } File name must be: Demo.java special thanks to Aditya Tandon and Rohit Negi sir

  • No alternative text description for this image

well done, keep going.🔥

Like
Reply

Great, keep gng brother 💯

See more comments

To view or add a comment, sign in

Explore content categories