DAY 13: CORE JAVA TAP Academy 🚀 Understanding Methods in Java – The 4 Core Types Every Beginner Should Know When learning Java, one concept that truly builds your foundation is Methods. A method is simply a block of code designed to perform a specific task. It improves code reusability, readability, and maintainability. In Java, methods can be categorized into 4 main types based on parameters (input) and return type (output): 1️⃣ No Input, No Output No parameters No return value (void) Just performs an action void greet() { System.out.println("Hello, World!"); } 👉 Used when you simply want to execute something without expecting any result. 2️⃣ No Input, With Output No parameters Returns a value int getNumber() { return 10; } 👉 Useful when a method generates or calculates something internally and returns it. 3️⃣ With Input, No Output Takes parameters Does not return anything void displaySum(int a, int b) { System.out.println(a + b); } 👉 Ideal when you pass data to perform an action like printing or updating. 4️⃣ With Input, With Output Takes parameters Returns a value int add(int a, int b) { return a + b; } 👉 This is the most commonly used type in real-world applications. 💡 Understanding these four types helps you design better programs and improves problem-solving skills. Strong fundamentals in Java lead to stronger logic building — and that’s the key to becoming a confident developer. #Java #Programming #Coding #JavaDeveloper #SoftwareDevelopment #LearningJourney
Java Methods: 4 Core Types for Beginners
More Relevant Posts
-
📘 Day 18 of My Java Learning Journey ☕💻 Today I learned about the concept of the main method and method types in Java, which help in writing structured, reusable, and organized programs. 👉 What is a Method? A method is a block of code that performs a specific task. It allows us to reuse code and avoid repetition in a program. 👉 What is Method Signature? A method signature consists of the method name and parameter list. It defines how the method is called. 👉 What is Method Declaration? The declaration specifies the return type, method name, and parameters. 👉 What is Method Definition? The definition contains the actual implementation of the method, where the program logic is written. 👉 Types of Method in Java I practiced today: 1️⃣ With return type and with arguments. 2️⃣ With return type and without arguments. 3️⃣ Without return type and without arguments. 4️⃣ Without return type and with arguments. Understanding the concept of method helps in breaking a program into smaller reusable parts, making the code easier to read and maintain. Step by step, I am strengthening my Java fundamentals. #JavaDeveloper #LearnJava #JavaProgramming #CodingJourney #DailyCoding #DeveloperJourney #CodePractice #ProgrammingLife #TechLearning
To view or add a comment, sign in
-
💫 Understanding Inheritance in Java | TAP Academy As part of my Java learning journey at TAP Academy, I explored the concept of Inheritance, one of the core principles of Object-Oriented Programming (OOP). 🔎 What is Inheritance? Inheritance is the process by which one class acquires the properties (variables) and behaviors (methods) of another class. In Java, inheritance is achieved using the extends keyword. 📌 Advantages of Inheritance ✅ Code Reusability ✅ Reduces development time and effort ✅ Improves productivity and maintainability 📚 Types of Inheritance 1️⃣ Single Inheritance One class inherits from another class. Example: ClassB extends ClassA ClassA │ ClassB 2️⃣ Multilevel Inheritance A class inherits from another class, and another class inherits from it. ClassA │ ClassB │ ClassC 3️⃣ Hierarchical Inheritance Multiple classes inherit from a single parent class. ClassA / \ ClassB ClassC 4️⃣ Hybrid Inheritance Combination of single inheritance and hierarchical inheritance. ClassA │ ClassB / \ ClassC ClassD 5️⃣ Multiple Inheritance A class inherits from more than one parent class. ⚠️ Note: Multiple inheritance is not supported in Java using classes because it creates the Diamond Problem. Diamond Problem Diagram ClassA / \ ClassB ClassC \ / ClassD Here, ClassD receives properties from both ClassB and ClassC, which both inherit from ClassA, causing ambiguity. 6️⃣ Cyclic Inheritance ClassA ←→ ClassB This occurs when classes depend on each other in a cycle. ⚠️ Note: Cyclic inheritance is not allowed in Java because it creates logical conflicts. 💡 Conclusion Inheritance helps developers reuse existing code, build relationships between classes, and create scalable applications. Learning these OOP concepts is helping me strengthen my Java programming fundamentals. #Java #OOP #Inheritance #JavaProgramming #CodingJourney #TAPAcademy #LearningJava #SoftwareDevelopment 💻
To view or add a comment, sign in
-
-
🚀 Starting My Java Learning Journey – Day 9 🔹 Topic: Method Overloading in Java Method Overloading is a feature in Java that allows a class to have multiple methods with the same name but different parameters. It helps improve code readability and flexibility. 📌 Ways to Achieve Method Overloading 1️⃣ Different number of parameters 2️⃣ Different data types of parameters 📌 Example Program public class Main { // Method with two int parameters static int add(int a, int b) { return a + b; } // Method with three int parameters static int add(int a, int b, int c) { return a + b + c; } public static void main(String[] args) { System.out.println(add(5, 10)); System.out.println(add(5, 10, 15)); } } Output: 15 30 💡 Key Points: ✔ Method overloading allows multiple methods with the same name ✔ Methods must differ in number or type of parameters ✔ Helps make programs more flexible and readable #Java #JavaLearning #Programming #BackendDevelopment #CodingJourney #MethodOverloading
To view or add a comment, sign in
-
Understanding static in Java | JVM Execution Flow 📍 Learned at TAP Academy As part of my Java learning journey at TAP Academy, I explored the concept of static and how it works inside the JVM. 🔎 What happens when a Java program runs? When we execute a Java program: 1️⃣ The JVM (Java Virtual Machine) loads the class into memory. 2️⃣ While loading the first class, JVM checks for: ✅ Static variables ✅ Static blocks ✅ Static methods 3️⃣ After loading static members, JVM looks for the entry point: public static void main(String[] args) ⚡ Why is main() static? Because the JVM must call it without creating an object of the class. 💡 What is static in Java? static members belong to the class, not to objects. Memory is allocated only once in the class area. Shared among all objects of the class. 🔹 Static Variable Common property shared by all objects. Saves memory because only one copy is created. 🔹 Static Block Executes only once when the class is loaded. Used for initialization of static variables. 🎯 Understanding static helped me clearly visualize how JVM loads classes and manages memory. Grateful to TAP Academy for strengthening my Java fundamentals 🙌 #Java #OOPS #JVM #TAPAcademy #Programming #LearningJourney
To view or add a comment, sign in
-
-
🚀 Day 16 | Core Java Learning Journey 📌 Topic: this, super & final Keyword (Java Keywords – Part 2) Today, I explored three very important Java keywords that control object behavior, inheritance, and immutability. 🔹 this Keyword in Java 1️⃣ this Variable ▪ Refers to the current object ▪ Used to resolve variable name conflicts ▪ Helps initialize instance variables 2️⃣ this Method ▪ Calls another method of the same class ▪ Improves readability & clarity 3️⃣ this Constructor ▪ Invokes another constructor in the same class ▪ Enables Constructor Chaining (important concept) ▪ Must be the first statement in constructor 🔹 super Keyword in Java (Used in Inheritance) 1️⃣ super Variable ▪ Refers to parent class variables ▪ Used when parent & child share same field names 2️⃣ super Method ▪ Calls parent class methods ▪ Useful when method is overridden 3️⃣ super Constructor ▪ Invokes parent class constructor ▪ Must be first statement in constructor ▪ If not written, compiler adds it automatically 🔹 final Keyword in Java 1️⃣ final Variable ▪ Value cannot be changed once assigned ▪ Used to create constants 2️⃣ final Method ▪ Cannot be overridden ▪ Ensures method behavior remains fixed 3️⃣ final Class ▪ Cannot be inherited ▪ Prevents extension 📌 Key Takeaway ✔️ this → Refers to current object / constructor chaining ✔️ super → Access parent class members ✔️ final → Restricts modification & inheritance Special thanks to Vaibhav Barde Sir for the clear explanations 🚀💻 #CoreJava #JavaLearning #OOP #ThisKeyword #SuperKeyword #FinalKeyword #JavaDeveloper #LearningJourney
To view or add a comment, sign in
-
-
📘 Java Learning Update | Deep Dive into the static Keyword As part of my Core Java training at TAP Academy, I implemented a Simple Interest calculator to understand the real-world usage of the static keyword in Java. Instead of treating it as just a formula-based program, I focused on how static works internally and why it is important in application design. 🔹 What I implemented: Took user input for principal amount and time Declared the interest rate as a static variable Used a static block to initialize the interest rate Calculated Simple Interest using structured methods 🔹 Key Concepts I Strengthened: ✔️ Difference between instance variables and class variables ✔️ How static variables are shared across all objects ✔️ When to use a static block ✔️ Memory-level understanding (class-level loading) ✔️ Writing optimized and structured OOP-based programs 💡 Why this matters in real-world development: Common values like tax rates, configuration settings, policies, and constants are usually declared as static because they belong to the class, not individual objects. Learning these core fundamentals is helping me build strong backend foundations and understand how scalable Java applications are structured. Grateful to be learning and implementing these concepts step by step at TAP Academy 🚀 #Java #CoreJava #StaticKeyword #OOP #BackendDevelopment #ProgrammingJourney #TapAcademy #LearningByDoing
To view or add a comment, sign in
-
-
🚀 Understanding Default, Static, and Private Methods in Java Interfaces As part of my learning journey at Tap Academy, I recently explored some powerful features introduced in Java interfaces starting from JDK 8 and JDK 9. These features allow interfaces to contain concrete methods, making them more flexible and powerful. Here’s a quick summary of what I learned: 🔹 Default Methods (JDK 8) The default keyword allows us to define concrete methods inside an interface. Example: public default void methodName() { // implementation } Key points: Default methods participate in inheritance. They can be overridden in the implementing (child) class. In the child class, we should NOT use the default keyword while overriding. Introduced mainly for backward compatibility, allowing new methods to be added to interfaces without breaking existing implementations. 🔹 Static Methods (JDK 8) Interfaces can also have static methods. Example: public static void methodName() { // implementation } Key points: Accessed using InterfaceName.methodName() Can be used without creating objects or implementing the interface Useful for utility/helper methods related to the interface Static methods cannot be overridden 🔹 Private Methods (JDK 9) Private methods were introduced to avoid code duplication inside interfaces. Example: private void methodName() { // implementation } Key points: Accessible only within the interface. Used to support default methods. Static methods cannot access non-static private methods. To solve this, we can create a private static method: private static void methodName() { // implementation } 🔹 Summary Interfaces can contain concrete methods using default, static, and private. default and static methods were introduced in JDK 8. private and private static methods were introduced in JDK 9. Grateful to Tap Academy for helping me understand these important Java concepts and strengthening my core Java knowledge. Looking forward to applying these concepts in real-world projects! #Java #CoreJava #JavaLearning #Programming #SoftwareDevelopment #JavaDeveloper #TapAcademy #LearningJourney TAP Academy
To view or add a comment, sign in
-
-
💻 Understanding the Object Class and toString() Method in Java Day 31 at #TAPACADEMY As part of my journey in learning Java and Object-Oriented Programming, I explored the Object class, which is the root of the entire Java class hierarchy. 🔹 Object Class in Java The Object class is the parent class of all classes in Java. Every class automatically inherits methods from it, either directly or indirectly. Some commonly used methods provided by the Object class include: ✔ equals() – Used to compare two objects ✔ hashCode() – Generates a unique hash value for objects ✔ clone() – Creates a copy of an object ✔ toString() – Returns the string representation of an object 🔹 toString() Method The toString() method is used to convert an object into a readable string representation. By default, it returns the class name and hash code, but it can be overridden to display meaningful information about an object. Overriding this method helps improve readability, debugging, and logging in Java applications. 📚 Understanding the Object class gives deeper insight into how Java manages objects and inheritance, making it a fundamental concept in mastering Java programming. Trainer : Sharath R #Java #ObjectOrientedProgramming #OOP #JavaDeveloper #Programming #LearningJourney #SoftwareDevelopment
To view or add a comment, sign in
-
-
🚀 Learning Update: Core Java – Encapsulation, Constructors & Object Creation In today’s live Java session, I strengthened my understanding of some fundamental Object-Oriented Programming concepts that are essential for writing secure and structured programs. ✅ Key Learnings: 🔹 Understood Encapsulation practically and why it is important for protecting sensitive data in applications. 🔹 Learned how to secure instance variables using the private access modifier. 🔹 Implemented setters and getters to provide controlled access to class data. 🔹 Understood the importance of validating data inside setter methods to prevent invalid inputs. 🔹 Practiced a real-world example using a Customer class with fields like ID, Name, and Phone. 🔹 Learned about the shadowing problem, which occurs when parameter names are the same as instance variables. 🔹 Understood that local variables have higher priority inside methods. 🔹 Solved this issue using the this keyword, which refers to the currently executing object. 🔹 Gained clarity on constructors and how they are automatically called when an object is created. 🔹 Learned that constructors must have the same name as the class and do not have a return type. 🔹 Explored different types of constructors: • Default constructor • Zero-parameterized constructor • Parameterized constructor 🔹 Understood constructor overloading and how Java differentiates constructors based on parameter count and type. 🔹 Learned how object creation works internally, including memory allocation and execution flow. 💡 Key Realization: Understanding these core OOP concepts helps in writing secure, maintainable, and industry-ready Java code. #Java #CoreJava #OOP #Encapsulation #Constructors #LearningUpdate #PlacementPreparation #SoftwareDevelopment TAP Academy
To view or add a comment, sign in
-
-
🚀Day 44 – Java Full Stack Learning with Frontlines EduTech (FLM) & Fayaz S. Today, I explored Java 8, which was introduced in 2014. Java 8 brought many important improvements to the language and made coding simpler and more readable. It introduced several new features that support functional-style programming and help reduce boilerplate code. 🔹 Functional Interface A Functional Interface is an interface that contains only one abstract method. It can have multiple default or static methods, but only one abstract method. We can use the @FunctionalInterface annotation to indicate that the interface is functional. This annotation is not mandatory, but it is recommended because it prevents accidental addition of extra abstract methods. Example: @FunctionalInterface interface MyFunctionalInterface { void display(); } 🔹 Default Method Java 8 introduced the default method feature, which allows us to write method implementation inside an interface. To define a default method: • The default keyword is mandatory • We can provide a method body inside the interface • It is not mandatory for the implementing class to override it Example: interface MyInterface { default void show() { System.out.println("This is a default method"); } } class Test implements MyInterface { public static void main(String[] args) { Test obj = new Test(); obj.show(); } } Here, the Test class can directly use the default method without overriding it. Today, I strengthened my understanding of Java 8 features, especially Functional Interfaces and Default Methods, and how they improve code flexibility and reusability. 🚀📈 #Java #JavaFeatures #JavaFullStack #FrontlinesEduTech #FullStackDeveloper #JavaDeveloper
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