Day 12 of Learning Java 💻 Today I learned something interesting about Runtime Polymorphism. In Java, the method that gets executed is decided at runtime, not at compile time. Even if a parent class reference is used, the child class method gets called. Example idea: Parent ref = new Child(); Even though the reference is of Parent type, the overridden method of Child runs. This is called Dynamic Method Dispatch. It works because of: ✔ Method Overriding ✔ Inheritance ✔ Upcasting It’s powerful because it allows flexibility and loose coupling in programs. Java decides which method to execute based on the object, not the reference type — and that’s what makes runtime polymorphism so interesting #Java #OOP #RuntimePolymorphism #MethodOverriding #DynamicMethodDispatch #100DaysOfCode #ProgrammingJourney #SoftwareDevelopment #CodingLife
Java Runtime Polymorphism: Dynamic Method Dispatch
More Relevant Posts
-
🚀 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 9 – Java Learning Journey Today I continued strengthening my Java fundamentals, focusing on method overriding and important rules in inheritance. Key concepts I explored: • Method Overriding Rules in Java The child class method must have the same method signature as the parent class method. The return type must be the same or covariant (a subclass of the parent return type). The method cannot be static, because static methods belong to the class rather than the object. • Covariant Return Types Java allows a child class method to return a more specific type than the parent class method, making inheritance more flexible. • Static vs Instance Methods I also learned why static methods cannot be overridden and are instead method hidden, which behaves differently from runtime polymorphism. Step by step, continuing to build a stronger foundation in Core Java and OOP concepts. 🚀 #Java #CoreJava #OOP #MethodOverriding #Programming #SoftwareDevelopment #LearningJourney
To view or add a comment, sign in
-
🚀 Today I Learned – Inheritance in Java •Today, I learned about Inheritance, the second pillar of Object-Oriented Programming (OOP) in Java. 🔹 Inheritance allows one class (child) to acquire properties and behaviors from another class (parent). 🔹 In Java, inheritance is achieved using the extends keyword. 🔍 Key Concepts I Covered: ✅ Single Inheritance – One parent → One child ✅ Multilevel Inheritance – Grandparent → Parent → Child ✅ Hierarchical Inheritance – One parent → Multiple children ✅ Hybrid Inheritance – Combination of inheritance types (concept exists) ❌ Multiple Inheritance – Not supported in Java classes 💎 Diamond Problem •I also understood why Java does not support multiple inheritance with classes — to avoid ambiguity when two parent classes contain the same method. Understanding inheritance helps in: •Code reusability •Better organization •Building scalable applications #Java #OOP #Inheritance #LearningJourney #SoftwareDevelopment #CoreJava #Programming #TapAcademy
To view or add a comment, sign in
-
-
Mutable vs Immutable Strings in Java In Java, the String class is immutable, meaning once an object is created, its value cannot be changed. Any operation like concatenation creates a new object in memory, which impacts performance when used repeatedly. To handle frequent modifications, Java provides mutable string classes: -> StringBuilder → Faster, not thread-safe (best for single-threaded tasks) -> StringBuffer → Thread-safe, synchronized, but a bit slower Choosing the right type improves performance, memory usage, and code efficiency. TAP Academy #Java #JavaDeveloper #Programming #CodingConcepts #LearningJourney 🚀
To view or add a comment, sign in
-
-
🚀 Exploring a New Feature in Java 25! Today I came across an interesting update in Java 25. Traditionally, every Java program required writing: public static void main(String[] args) But with the newer version, Java has simplified this! Now we can simply write: void main() { System.out.println("Hello World"); } And the program runs successfully 🎉 This makes Java more beginner-friendly and reduces boilerplate code, especially for simple programs and learning purposes. It’s great to see Java evolving to improve developer experience while maintaining its powerful ecosystem. Have you tried this new feature yet? 💻✨ #Java #Java25 #Programming #SoftwareDevelopment #Learning
To view or add a comment, sign in
-
-
Today, I strengthened my understanding of Method Overloading in Java — an important concept of compile-time polymorphism. 🔹 Key Rules I Learned: ✔ Method name must be the same ✔ The number of parameters can be different ✔ The data type of parameters can be different ✔ The order of parameters can be different ✔ Changing only the return type does NOT support overloading 🔹 Understanding Type Promotion Java follows this order during method resolution: byte → short → int → long → float → double Java first looks for an exact match. If not found, it promotes the smaller data type to the next higher type. Practicing these fundamentals is helping me build a strong base in Core Java and improve my problem-solving skills step by step. TAP Academy #Java #CoreJava #MethodOverloading #Programming #JavaDeveloper #LearningJourney
To view or add a comment, sign in
-
-
Day 5 of My Java Learning Journey Today I learned about Methods, Method Overloading, and Method Overriding in Java. >>Methods: A method is a block of code that performs a specific task. It helps in code reusability and makes the program more organized and readable. Basic structure of a method: *Access modifier *Return type *Method name *Parameters *Method body >>Method Overloading: Method overloading means having multiple methods with the same name but different parameters (different number or type of arguments) in the same class. >>Method Overriding: Method overriding happens when a child class provides its own implementation of a method that is already defined in the parent class. #Java #OOPS #MethodOverloading #MethodOverriding #LearningInPublic
To view or add a comment, sign in
-
🚀 Learning Java – Day 22 Today I explored functional interfaces and anonymous inner classes in Java. 🔹 I created an interface CharChecker with a method checkChar(char a). 🔹 Using an anonymous inner class, I implemented logic to check whether the ASCII value of a given character is a prime number. 🔹 The program converts the character into its ASCII integer value, then applies prime-checking logic: Handles base cases (<=1, =2, even numbers). Uses a loop to check divisibility up to √n. 🔹 Finally, it prints whether the ASCII value is prime or not. 👉 Example: Passing 'A' (ASCII 65) results in “65 Not prime”. This exercise helped me strengthen my understanding of: Functional interfaces Anonymous inner classes #JavaLearning #Day22OfCode #FunctionalInterfaces #AnonymousInnerClass #PrimeNumberLogic #JavaProgramming #CodeNewbie #LearningJourney #100DaysOfCode #DeveloperLife
To view or add a comment, sign in
-
Day 20 at Tap Academy |Understanding Immutable Strings in Java Today I learned an important concept in Java Strings the difference between immutable and mutable strings, and how StringBuffer and StringBuilder help in handling mutable string operations efficiently. In Java, the String class is immutable, which means once a string object is created, its value cannot be changed. Any modification like concatenation creates a new object in memory. To overcome this limitation, Java provides two mutable classes: 🔴StringBuffer Mutable (can modify content without creating new objects) Thread-safe (synchronized) Slower compared to StringBuilder Used in multi-thread environments 🔴StringBuilder Mutable Not thread-safe Faster than StringBuffer Preferred in single-threaded applications Why use them? When performing multiple string operations (append, insert, delete, reverse), using StringBuffer or StringBuilder improves memory efficiency because they modify the same object instead of creating new ones. #Java #CoreJava #StringBuffer #StringBuilder #MutableStrings #TapAcademy #LearningJourney #JavaDeveloper
To view or add a comment, sign in
-
-
In today's Core Java session, we explored how Java supports compile-time polymorphism by allowing multiple methods with the same name but different parameter lists. What seemed confusing at first became crystal clear through real-time coding and practical implementation under the guidance of Sharath R Sir at TAP Academy What I learned today: What compile-time polymorphism really means Changing number, type & order of parameters * How the compiler decides which method to execute * Writing cleaner, reusable, and structured code Instead of creating multiple method names, overloading helps maintain flexibility while keeping the code clean and readable. Every concept is adding one more strong brick to my Core Java & OOP foundation. #Java #CoreJava #OOP #MethodOverloading #Polymorphism #FullStackDeveloper #LearningJourney #TapAcademy Bibek Singh
To view or add a comment, sign in
-
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