A Java Marker Interface is an empty interface used to “mark” a class so that the JVM or frameworks can apply specific behaviour at runtime. Instead of defining methods, it acts as a signal for example, implementing "Serializable" tells the system that an object can be converted into a byte stream. In production systems, marker interfaces help frameworks detect capabilities of classes without tightly coupling logic to specific implementations. They often appear in discussions around serialisation, cloning, and framework behaviour. From an interview perspective, they are also useful when comparing older Java design patterns with modern alternatives such as annotations. In modern Java development, when would you prefer using a marker interface instead of annotations to indicate behaviour in a system? #Java #ObjectOrientedProgramming #BackendDevelopment #SoftwareEngineering #JavaDeveloper #InterviewPreparation
Java Marker Interface: Signaling Behaviour for JVM and Frameworks
More Relevant Posts
-
☕ #ThinkingInJava — Post No. 6 💡 Tricky Exception Handling Behavior Consider this code: class Test { public static void main(String[] args) { try { System.out.println(10/0); } catch (ArithmeticException e) { System.out.println(10/0); } finally { String s = null; System.out.println(s.length()); } } } 🤔 What will be the final exception? Many expect ArithmeticException. But the output is: Exception in thread "main" java.lang.NullPointerException 🎯 Key Concept 👉 The default exception handler handles only ONE exception at a time — the most recently raised exception. Execution flow: 1️⃣ 10/0 in try → ArithmeticException 2️⃣ 10/0 in catch → ArithmeticException again 3️⃣ s.length() in finally → NullPointerException Since the finally block runs last, the NullPointerException becomes the most recent exception. So the JVM reports NullPointerException, not ArithmeticException. 🔖 Takeaway When multiple exceptions occur, the most recently thrown exception is the one handled by the JVM's default exception handler. #Java #AutomationMeetsFuture #TestAutomationSpecialist
To view or add a comment, sign in
-
🔍 Initialization Blocks in Java – Static vs Non-Static While revisiting core Java concepts, I explored how Initialization Blocks work and how they affect object creation and class loading. 1️⃣ Static Initialization Block • Used to initialize static variables • Executed only once when the class is loaded • Runs before the "main()" method 2️⃣ Non-Static (Instance) Initialization Block • Used to initialize instance variables • Executes every time an object is created • Runs before the constructor ⚙ Execution Order in Java 1. Static Block 2. "main()" method 3. Instance (Non-Static) Block 4. Constructor Understanding this order helps when debugging initialization logic and designing classes with controlled object creation. #Java #Programming #BackendDevelopment #SoftwareEngineering #JavaDeveloper
To view or add a comment, sign in
-
-
Day 40 – Advanced Java Strings & Input Handling ☕ Today I revised advanced concepts related to Strings and input handling in Java. Topics covered: 🔹 Inbuilt String methods 🔹 Converting String to character array 🔹 Mutable vs Immutable Strings 🔹 Difference between StringBuilder and StringBuffer 🔹 Handling input using nextLine() with integers and strings 🔹 Understanding buffer issues in input handling 🔹 Converting mutable to immutable and vice versa 🔹 Difference between split() and StringTokenizer Revisiting these concepts helped me better understand how Java handles strings internally and how input operations can sometimes lead to unexpected issues if not handled properly. Strengthening core concepts step by step 🚀 #Day40 #JavaJourney #Strings #CoreJava #ProgrammingFundamentals
To view or add a comment, sign in
-
📘 1. TOP 15 CORE JAVA QUESTIONS (WITH SHORT ANSWERS) 🔥 Core Java (1–15) 1. What is JVM? → Runs Java bytecode 2. JDK vs JRE → Dev vs Runtime 3. == vs equals() → Reference vs Content 4. Why String immutable? → Security + caching 5. String pool? → Memory optimization 6. OOP principles → 4 pillars 7. Encapsulation → Data hiding 8. Inheritance → Code reuse 9. Polymorphism → Many forms 10. Abstraction → Hiding complexity 11. final vs finally vs finalize 12. Exception hierarchy 13. Checked vs unchecked 14. Multithreading → concurrency 15. Synchronization → thread safety # java #Code #Java #springboot
To view or add a comment, sign in
-
📌 Command Design Pattern Explained (with Java example) The Command Pattern is a behavioral design pattern that encapsulates a request as an object, helping decouple the sender from the receiver. It is commonly used for: • Undo/redo functionality • Task queues • Logging and command history I wrote a short article explaining the concept with a simple and practical Java example. 📖 Read it here: https://lnkd.in/g4-XS8Dh #Java #DesignPatterns #SystemDesign #BackendDevelopment
To view or add a comment, sign in
-
Most Java developers know about Strings… but many don’t fully understand how the String Pool actually works. In Java, Strings can be initialized in two ways, and depending on how they are created, they are stored differently in memory. Java maintains a special memory area called the String Pool inside the heap to optimize memory usage. 1️⃣ String Literal Initialization 2️⃣ Using the new Keyword Check the visual below to understand how String literals and new String() objects are stored in Java memory. #Java #JavaDeveloper #BackendDevelopment #JavaProgramming #SoftwareEngineering #JavaInterview #CodingConcepts #LearnJava
To view or add a comment, sign in
-
-
☕ #ThinkingInJava — Post No. 5 💡 Tricky Java Question What will be the output? class Test { public static int m1() { int i = 10; try { return i; } finally { i = 20; System.out.println("finally block executed"); } } public static void main(String[] args) { System.out.println(m1()); } } ✅ Output finally block executed 10 🤔 Why not 20? When return i executes, Java first saves the return value internally. temp = i // temp = 10 Then the "finally" block runs, changing i to 20. But the method returns the saved value (10). 🎯 Key Concept 👉 The return value is evaluated before the `finally'. #Java #TestAutomationSpecialist #AutomationMeetsFuture
To view or add a comment, sign in
-
🧬 Java Collections – ArrayList Deep Dive Yesterday I explored ArrayList in more detail. ✔️ Looping through elements ✔️ Using methods like remove(), contains(), and size() Understanding these operations helps in managing dynamic data effectively in Java. Also practiced DSA problems like: • Removing even numbers from a list • Finding common elements between two lists Strengthening both collection usage and problem-solving together. 🚀 #Java #Collections #DSA #LearningInPublic #BackendDevelopment #DeveloperJourney
To view or add a comment, sign in
-
Java Streams Series – Day 7 Today I explored an efficient approach to check whether a string is a palindrome using Java Streams. Instead of using traditional loops or reversing the string, this approach applies a functional style to compare characters from both ends, progressing toward the center. By iterating through only half of the string, it maintains optimal performance while keeping the implementation concise and readable. This reinforces how Java Streams can help write clean, declarative, and efficient code for common problems. #Java #JavaStreams #CleanCode #FunctionalProgramming #100DaysOfCode
To view or add a comment, sign in
-
-
Your Java Thread Model is Broken (Here's the Fix) Watch Full Video : https://lnkd.in/e_Usi8qA Website Link : https://systemdrd.com/ Full Course Link : https://lnkd.in/eM5jJyaQ OS threads cost 1MB each and cap you at ~2,000 connections. Java's virtual threads via Project Loom handle 1,000,000+ — with simpler code. Stop writing reactive chains. #JavaDeveloper #ProjectLoom #VirtualThreads #BackendEngineering #JavaTips #CodingShorts #SoftwareEngineering #Java2026
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