🚀 Day 58 of 100 Days of Java Topic: Normal Interface in Java In Java, an interface is like a contract — it tells what a class must do, but not how to do it. A normal interface contains abstract methods only (no implementation). Any class that implements it must provide concrete implementations for all those methods. A normal interface is also called as regular interface 💡 Key Points: All methods in a normal interface are public and abstract by default. A class that implements the interface must override and define all the abstract methods. Variables in an interface are public, static, and final by default. You cannot create an object of an interface directly. It supports multiple inheritance — one class can implement multiple interfaces. Why use it? To achieve abstraction (hide implementation details). To achieve loose coupling between components. To enable multiple inheritance in Java. 10000 Coders Gurugubelli Vijaya Kumar #java #Interfaces #NormalInterface #javafullstack
Understanding Normal Interfaces in Java
More Relevant Posts
-
Day43 - Interface in Java. 1. Interface is like a blueprint of a class — it contains methods (usually without body) that a class must implement. 2. It is used to achieve abstraction and multiple inheritance in Java. Interface in Java 7 : 1. Only abstract methods are allowed (no method body). 2. Only public static final variables (constants) are allowed. 3. A class implements an interface using the implements keyword. 4. A class must implement all abstract methods of the interface. Interface in Java 8 Java 8 made interfaces more powerful by allowing default and static methods. 1.Default Methods: Can have a method body inside interface. Used to add new features to interfaces without breaking old code. Must be marked with the keyword default. Interface in Java 9 and above 1. Java 9 added private methods inside interfaces. 2. Private Methods: Used only inside the interface. Helps to avoid code duplication in default and static methods. Cannot be accessed outside the interface. 2.Static Methods: Can be called using Interface name, not through objects. Used for utility or helper methods. Gurugubelli Vijaya Kumar 10000 Coders #Java #Interfaces #CoreJava #OOPS #Abstraction #Java8 #Java9 #LearnJava #CodingConcepts #SoftwareDevelopment
To view or add a comment, sign in
-
Day 57 of 100 Days of Java — Interface Types in Java In Java, an interface defines a contract of methods that must be implemented by the classes using it. there are different types of interfaces in Java based on their method structure and purpose 1.Normal Interface A regular interface containing one or more abstract methods. Used when: Multiple methods need to be implemented by different classes. 2.Functional Interface An interface with exactly one abstract method (can have multiple default/static methods). Annotated with @FunctionalInterface. SAM Interface(Single Abstract Method)another name for a Functional Interface. Used mainly with Lambda Expressions and Streams API. Used for: Lambda expressions and functional programming Introduced in Java 8. 3.Marker Interface An empty interface (no methods at all). It gives metadata to JVM or compiler. Examples: Serializable, Cloneable, Remote Used for: Providing special information or behavior to the class. Key Takeaways Interfaces promote abstraction and loose coupling. Functional Interfaces enable modern Java functional programming. Marker Interfaces communicate intent to JVM. My Learning Reflection Understanding different interface types helped me write cleaner, modular, and more reusable Java code. Each type has a unique role in real-world applications — from designing APIs to using Lambda expressions efficiently. 🧵 #100DaysOfJava #JavaLearning #FunctionalInterfaces #OOPsInJava #CodingJourney
To view or add a comment, sign in
-
#Day11 – Java Tricky Interview Question 🐱💻 From Java 8 → Java 25 — The Evolution Journey 🌟 💡 In just one decade, Java transformed from Lambdas → Virtual Threads → Stream Gatherers! 🧩 Code Evolution Example // ☕ Java 8 → Functional Revolution List.of(1,2,3,4).stream() .filter(n -> n % 2 == 0) .forEach(System.out::println); // ⚡ Java 21 → Concurrency Revolution Thread.ofVirtual().start(() -> System.out.println("Hello from Virtual Thread!")); // 🧠 Java 25 → Stream Revolution import java.util.stream.Gatherers; List.of("A", "B", "C", "D").stream() .gather(Gatherers.windowFixed(2)) .forEach(System.out::println); 🔍 Key Takeaways 🔸 Java 8 → Lambdas, Streams, Functional Magic ✨ 🔸 Java 21 → Virtual Threads = Lightweight Concurrency ⚙️ 🔸 Java 25 → Stream Gatherers = Custom Stream Operations Simplified 💡 #Java25 #JavaDeveloper #ModernJava #VirtualThreads #StreamGatherers #JavaEvolution #CodingJourney
To view or add a comment, sign in
-
💡 𝗝𝗮𝘃𝗮/𝐒𝐩𝐫𝐢𝐧𝐠 𝐁𝐨𝐨𝐭 𝗧𝗶𝗽 - 𝗡𝘂𝗹𝗹 𝗔𝗿𝗴𝘂𝗺𝗲𝗻𝘁 𝗚𝘂𝗮𝗿𝗱𝘀 🔥 💎 𝗧𝗵𝗿𝗲𝗲 𝗪𝗮𝘆𝘀 𝘁𝗼 𝗚𝘂𝗮𝗿𝗱 𝗔𝗴𝗮𝗶𝗻𝘀𝘁 𝗡𝘂𝗹𝗹 𝗔𝗿𝗴𝘂𝗺𝗲𝗻𝘁𝘀 💡 𝗧𝗿𝗮𝗱𝗶𝘁𝗶𝗼𝗻𝗮𝗹 𝗶𝗳 𝗖𝗵𝗲𝗰𝗸 𝗮𝗻𝗱 𝗧𝗵𝗿𝗼𝘄 This approach uses a manual null check to validate if the argument is null. If it is, an 𝗜𝗹𝗹𝗲𝗴𝗮𝗹𝗔𝗿𝗴𝘂𝗺𝗲𝗻𝘁𝗘𝘅𝗰𝗲𝗽𝘁𝗶𝗼𝗻 is thrown with a descriptive message. Works in all Java versions and provides full control over exception handling. 👍 𝗢𝗯𝗷𝗲𝗰𝘁𝘀.𝗿𝗲𝗾𝘂𝗶𝗿𝗲𝗡𝗼𝗻𝗡𝘂𝗹𝗹 Introduced in Java 7, this is the most concise and expressive way to perform null checks. The method automatically throws a 𝗡𝘂𝗹𝗹𝗣𝗼𝗶𝗻𝘁𝗲𝗿𝗘𝘅𝗰𝗲𝗽𝘁𝗶𝗼𝗻 if the argument is null. This is now the recommended approach for modern Java applications. 🔥 𝗢𝗽𝘁𝗶𝗼𝗻𝗮𝗹.𝗼𝗳𝗡𝘂𝗹𝗹𝗮𝗯𝗹𝗲 𝘄𝗶𝘁𝗵 𝗼𝗿𝗘𝗹𝘀𝗲𝗧𝗵𝗿𝗼𝘄 The 𝗢𝗽𝘁𝗶𝗼𝗻𝗮𝗹 API allows you to wrap potentially null values and handle them safely. Using 𝗼𝗿𝗘𝗹𝘀𝗲𝗧𝗵𝗿𝗼𝘄, you can throw a custom exception if the value is absent. This approach is ideal when working with nullable parameters in functional-style code. 🤔 Which one do you prefer? Can you suggest another way? #java #springboot #programming #softwareengineering #softwaredevelopment
To view or add a comment, sign in
-
-
💡 Understanding System.out.println() in Java System.out.println() is one of the very first statements every Java programmer learns — and for a good reason! It’s how Java prints messages to the console and helps us understand what our program is doing at each step. Let’s break it down part by part: 🔹1. System System is a predefined class in the java.lang package. It provides many useful objects and methods related to the system environment. You don’t need to import it — Java loads it automatically. 🔹2. out out is a static variable inside the System class. It represents the standard output stream, usually your console. Think of it like Java’s built-in “speaker” that prints messages. 🔹3. println() println() is a method of the PrintStream class (which System.out refers to). It prints the message and then moves the cursor to the next line. If you don’t want a new line, you can use print() instead. Even though it looks simple, System.out.println() is the foundation for debugging, testing, and understanding Java logic. Mastering the basics is what truly builds strong programmers! 💻✨ A big thank you to Anand Kumar Buddarapu Sir for always reminding us about the importance of fundamentals and clear understanding. #Java #Programming #CodingBasics #SystemOutPrintln #CoreJava #Debugging #LearnJava #CodingJourney #JavaDeveloper
To view or add a comment, sign in
-
-
Day 2 of My 90-Day Java Journey — Understanding Multithreading in Java Have you ever downloaded a file while listening to music and chatting online at the same time? 🎧💬💾 That’s multitasking — and in Java, it’s called Multithreading. ⸻ 🧠 What is Multithreading? Multithreading means executing multiple tasks (threads) simultaneously within a single program. It helps improve performance and keeps applications fast and responsive. ⸻ 💡 Real-life Example: Imagine you’re in a restaurant 🍽️ • One cook is preparing food 🍳 • Another is baking dessert 🍰 • Another is serving customers 🍹 They all work in parallel, so customers get faster service — that’s multithreading in action! 🚀 Why It Matters: ✅ Faster performance ✅ Better resource utilization ✅ Smooth user experience (especially in web or GUI apps) #Java #Multithreading #BackendDevelopment #JavaThreads #CodingJourney #LearnJava #90DaysOfCode
To view or add a comment, sign in
-
-
Day 1 of java fullstack development........ Today we are started basics of java and conditional statements 1. if 2. if else 3. else if 4. nested if 5. switch if, if else , else if are called as conditional based conditional statements. Today I learned something really interesting in Java — the enhanced switch case using arrow (→) syntax. It makes the code cleaner, faster, and easier to read compared to the traditional switch statement. 💡 Here’s a small example : follow below 👇 ..... int day = 3; String dayType = switch (day) { case 1, 2, 3, 4, 5 -> "Weekday"; case 6, 7 -> "Weekend"; default -> "Invalid day"; }; System.out.println(dayType); ✅ No need for break statements ✅ Compact and readable code ✅ Perfect for modern Java development I’m really enjoying learning Java Full Stack Development — every day something new to explore! 💻✨ THANK YOU EVERYONE..... ☺️ #Java #LearningJourney #FullStackDevelopment #Coding #SwitchCase #JavaDeveloper
To view or add a comment, sign in
-
✨Understanding the ‘final’ Keyword in Java Inheritance In Java, the final keyword is used to impose restrictions on classes, methods, and variables. It ensures stability, security, and controlled behavior in object-oriented programming. Here’s how it works 👇 🔹 If a class is declared as final, it cannot be inherited by any other class. This prevents further extension and keeps the class implementation secure. 🔹 If a method is declared as final, it cannot be overridden by its subclass. This preserves the original logic of the method and avoids accidental changes. 🔹 If a variable is declared as final, its value cannot be modified once assigned. This makes it a constant throughout the program. 💡 Why use final? Because sometimes, we need to lock specific parts of our code to maintain consistency and avoid misuse. The final keyword acts as a protective boundary, ensuring our code behaves exactly as intended — even in complex inheritance hierarchies. ✨final = Control + Security + Stability Thanks to Anand Kumar Buddarapu sir for clearly explaining the concept of the final keyword in Java and helping me understand its role in inheritance. #Java #InheritanceInJava #FinalKeyword #LearnJava #JavaProgramming #ProgrammingConcepts
To view or add a comment, sign in
-
-
🔹 Method Reference in Java Method Reference is one of the elegant features introduced in Java 8, designed to make code cleaner and more readable. ✅ It is an improvement over Lambda Expressions. ✅ Instead of writing the entire body of a Lambda, we can directly refer to an existing method — either from our project or from the Java API. ✅ It helps in reusing existing code and writing concise, expressive code. 💡 Types of Method References 1️⃣ Instance Method Reference 👉 objectName::instanceMethodName 2️⃣ Static Method Reference 👉 ClassName::staticMethodName 3️⃣ Constructor Reference 👉 ClassName::new 4️⃣ Arbitrary Object Type Method Reference 👉 ClassName::instanceMethodName 🧠 Example: List<String> names = Arrays.asList("Mahesh", "Ravi", "Suresh"); names.forEach(System.out::println); Here, System.out::println is a method reference replacing the Lambda expression name -> System.out.println(name) ✅ 🚀 In short: Method references make Java code simpler, cleaner, and more reusable — a small feature with a big impact on code readability! #Java #Java8 #MethodReference #LambdaExpression
To view or add a comment, sign in
-
💡 Understanding the Copy Constructor in Java 🛠️ When you need to create a new object that is an exact replica of an existing object, the most reliable approach is often to use a Copy Constructor. This is a powerful, yet often overlooked, mechanism for object duplication. What is a Copy Constructor? A Copy Constructor is simply a constructor that accepts a single argument of the same class type as itself. Why Do We Need It? In Java, simply using Object newObj = originalObj; doesn't create a new object; it just creates a second reference pointing to the same object in memory. The Copy Constructor ensures you get a genuinely new, separate object initialized with the data from the original.
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