🚀 Day 35 – Exception Handling in Java Today I learned about Exception Handling in Java and specifically focused on Unchecked Exceptions. 💡 What are Unchecked Exceptions? Unchecked exceptions occur at runtime. They are not checked at compile time and usually happen due to logical mistakes in the program. 🔴 1️⃣ ArithmeticException 👉 Occurs when an illegal arithmetic operation is performed. Most common example: Division by zero Example situation: Dividing a number by 0 Performing invalid mathematical calculations 📌 Lesson: Always validate input before performing calculations. 🔴 2️⃣ NullPointerException 👉 Occurs when we try to use a reference variable that is null. Example situation: Calling a method on a null object Accessing or modifying a null object 📌 Lesson: Always check for null before accessing objects. 🧠 What I Understood Today ✔ Runtime errors are dangerous if not handled properly ✔ Proper validation prevents most unchecked exceptions ✔ Writing defensive code makes applications stable Small concepts, but very powerful in real-world applications 💪 Thank you to my mentor Suresh Bishnoi and Kodewala Academy for continuous support 🙏 #Day35 #100DaysOfCode #Java #ExceptionHandling #UncheckedException #LearningJourney #KodewalaAcademy
Java Exception Handling: Unchecked Exceptions
More Relevant Posts
-
📘 Day 26 – Understanding Java Constructors & Memory (Stack vs Heap) Today’s class gave a clear understanding of how Java handles object creation using constructors and how memory is allocated behind the scenes. 🔹 Key Learnings: ✔️ A constructor is a special method used to initialize objects ✔️ It is automatically called when an object is created using "new" ✔️ Instance variables are stored in Heap memory ✔️ Reference variables are stored in Stack memory 💡 Example Insight: When we create an object like: "Customer c = new Customer(1, "Arun", 214312);" 👉 The reference "c" is stored in Stack 👉 The actual object data (cId, cName, cNum) is stored in Heap This concept helped me visualize how Java manages memory efficiently and how objects interact internally. 🚀 Understanding memory flow is a crucial step toward writing optimized and bug-free Java programs. #Java #Programming #Learning #Coding #Developers #100DaysOfCode #JavaBasics #TechJourney#TapAcademy # Harshit T
To view or add a comment, sign in
-
-
Day 29 of Learning Java 🚀 Today I went deeper into understanding how Java actually runs behind the scenes inside the JVM. Some interesting things I discovered today: ⚡ Learned the execution order in Java when a program has static variables → static blocks → instance variables → instance blocks → constructors → methods. ⚡ The JVM usually checks static members first. If there are no static members, execution starts from main() since it is also a static method. ⚡ Understood the use of static variables and how they save memory by storing values in a shared memory area (static segment / class area). ⚡ Learned that objects are also called instances. ⚡ Important concept: Instance variables cannot be accessed directly by static methods Static variables can be accessed by instance methods ⚡ Learned how static blocks can initialize static variables. ⚡ Explored JVM components like Class Loader, Interpreter, and JIT compiler. ⚡ Practiced compiling and running Java programs using Command Prompt (javac and java). ⚡ Also understood that the number of bytecode (.class) files generated depends on how many classes exist in the program. Small steps every day, but building strong Core Java fundamentals. 💻 #Day29 #Java #CoreJava #JVM #Programming #LearningJourney Harshit T
To view or add a comment, sign in
-
-
Method Overloading in Java -> more than just same method names Method overloading allows a class to have multiple methods with the same name but different parameter lists. Java decides which method to call based on the method signature, which includes: • Number of parameters • Type of parameters • Order of parameters One important detail many people miss: Changing only the return type does not create method overloading. Why does this concept matter? Because it improves code readability and flexibility. Instead of creating different method names for similar operations, we can keep the same method name and let Java decide the correct one during compile time. That’s why method overloading is also called compile-time polymorphism. Small concepts like this form the foundation of how Java’s Object-Oriented Programming model really works. #Java #JavaProgramming #OOP #BackendDevelopment #CSFundamentals
To view or add a comment, sign in
-
-
Day 4 of Java Fundamentals 🚀 Today I revised the Inheritance in Java. Inheritance allows a class to acquire properties and methods of another class. Benefits: ✔ Code reusability ✔ Reduced duplication ✔ Better code structure Example: Dogs inherit behavior like eat() from Animal. 🔹 Multiple Inheritance in Java Java does not support multiple inheritance using classes to avoid complexity (diamond problem). However, it can be achieved using interfaces. 🔹 What is an Interface? An interface is a blueprint that contains abstract methods. A class can implement multiple interfaces, allowing Java to achieve multiple inheritance in a safe way. Example: A class can implement both Printable and Scannable interfaces. Learning Java fundamentals step by step to strengthen my core concepts 💻 #Java #LearningInPublic #SoftwareDevelopment #JavaDeveloper
To view or add a comment, sign in
-
🚀 Today I Learned – Java Static in Inheritance & Object Class Today I strengthened my understanding of some important Java concepts: 🔹 Static Variable Inheritance Static variables are inherited, but only one shared copy exists across the entire class hierarchy. 🔹 Static Methods & Method Hiding Static methods are inherited, but they cannot be overridden — they are hidden based on the reference type. 🔹 Execution Order in Inheritance Understanding the flow is important: Static Block → Instance Block → Parent Constructor → Child Constructor 🔹 Object Class as Root Every class in Java automatically inherits from the Object class. 🔹 Default vs Custom toString() By default, toString() returns: ClassName@Hashcode But we can override it to return meaningful and readable output. ✨ Small concepts, but very important for writing clean and predictable Java programs. TAP Academy #Java #OOP #Programming #LearningJourney #ComputerScience #JavaDeveloper #TapAcademy
To view or add a comment, sign in
-
-
✨ DAY-39: 🌳 Understanding DRY Principle in Java through Nature While learning Java, I came across the powerful concept of DRY (Don’t Repeat Yourself) — and the best way I visualized it is through a tree. In nature, a tree doesn’t grow multiple trunks for the same purpose. Instead, it has one strong trunk that supports many branches. 💡 Similarly in Java: Avoid writing the same code again and again Create reusable methods or functions Maintain a single source of truth 🌿 Without DRY: Imagine creating multiple trees for every branch → messy, hard to maintain ❌ 🌿 With DRY: One strong tree (method/class) → multiple branches (reuse) ✅ 👨💻 Java Example: Instead of repeating logic: System.out.println("Welcome"); System.out.println("Welcome"); Use DRY: public void printMessage() { System.out.println("Welcome"); } ✨ Call the method whenever needed! 🚀 Key Benefits: ✔ Cleaner code ✔ Easier maintenance ✔ Better readability ✔ Reduced errors 🌱 Write once, reuse everywhere — just like a tree grows efficiently from a single root. #Java #CleanCode #DRYPrinciple #Programming #CodingJourney #SoftwareDevelopment
To view or add a comment, sign in
-
-
A Tiny Java Mistake That Causes a Compile Error ❗ A Pitfall in Java: Why int i =08 doesn't work? Many developers get confused when Java throws an error for 08. The reason is simple but often overlooked. If a number starts with 0, Java treats it as an Octal number! (Base 8). Octal numbers only allow digits 0–7. That’s why: 08 ❌ 09 ❌ 010 ✔ (equals 8 in decimal) Small Java details like this can save hours of debugging. Swipe through the carousel to understand this Java concept clearly. #Java #JavaDeveloper #Programming #CodingTips #SoftwareEngineering #TechLearning #JavaForbeginners #JavaTipsForProfessionals
To view or add a comment, sign in
-
When I first started learning Java, garbage collection felt like magic. 1)You create objects. 2)The program get runs. 3)Unused memory gets cleaned up. But Java memory is not just one big box. Here is the simple model: * New objects start in Young Generation * Long-living objects move to Old Generation * Unused objects get removed by the Garbage Collector Example: A temporary list created inside a method usually dies young and gets cleaned quickly. But something like cache data or a session object can survive longer and move to the Old Generation. That matters because: * Young Generation collection is usually fast * Old Generation collection is heavier * Understanding both helps you reason about performance #Java #SpringBoot #BackendDevelopment #SoftwareEngineerr #javadeveloper
To view or add a comment, sign in
-
-
Day 8 of Java Fundamentals 🚀 Today I started learning the Java Collections Framework, which is widely used in real-world applications. 🔹 List → Ordered, allows duplicates 🔹 Set → No duplicates 🔹 Map → Stores key-value pairs Understanding collections is essential for handling data efficiently in Java applications. Excited to dive deeper into this topic 💻 #Java #LearningInPublic #JavaDeveloper #Collections
To view or add a comment, sign in
-
🚀 Understanding Exception Handling in Java Today, I explored the concept of exception handling in Java and how it helps in building robust and reliable applications. An exception is an unexpected event that occurs during program execution, which can disrupt the normal flow of the program. To handle such situations, Java provides try and catch blocks. 🔹 The try block is used to enclose code that may generate an exception. 🔹 The catch block is used to handle the exception and prevent the program from crashing. When an exception occurs, Java creates an exception object containing details like the error type, location, and cause. This object is passed to the runtime system, which looks for a matching catch block to handle it. If handled properly, the program continues execution smoothly. Otherwise, the default exception handler terminates the program and displays an error message. 💡 Learning exception handling is essential for writing clean, error-free, and maintainable Java applications. #Java #ExceptionHandling #Programming #Learning #SoftwareDevelopment #TapAcademy
To view or add a comment, sign in
-
More from this author
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
Thank you for mentioning