💡 Java Tricky Interview Question 25 Is it possible to create a class in Java without any methods or fields? 🤔 Sounds pointless, right? But technically, yes — and in this video, we’ll explain how it works, what the JVM does in such cases, and some rare but practical reasons for doing it. 🔥 What You’ll Learn in This Video: ✅ Can a class exist without methods and fields ✅ What happens behind the scenes in such a class ✅ When would you need a class like this ✅ Special scenarios: marker classes, placeholders, frameworks ✅ Default methods inherited from `Object` class 📌 Quick Answer: ✔️ Yes — you can create a class in Java without any methods or fields. Such a class can still be instantiated and participate in inheritance, thanks to the implicit methods inherited from `java.lang.Object`. 🧠 Deeper Explanation: ✅ What Happens in an Empty Class? Even if you don’t define any methods or fields, your class automatically inherits methods from `java.lang.Object`, like: `toString()` `hashCode()` `equals()` `getClass()` `wait()`, `notify()`, `notifyAll()` It still has a default public noargument constructor, added by the compiler if none is provided. ✅ Can You Instantiate It? Yes! You can create an instance of such a class using: ```java EmptyClass obj = new EmptyClass(); ``` It won’t do much on its own, but it’s still a valid object. ✅ Why Would You Do This? Marker/Tagging Interfaces or Classes Example: `Serializable`, `Cloneable`, or custom marker classes used for type identification Placeholder / Dummy Classes Temporarily used in frameworks or during development Control / Signal Objects To indicate a state or event in eventdriven programming ⚠️ Important Notes: ⚠️ Even “empty” classes aren’t truly empty — they still inherit from `Object`. ⚠️ Marker classes and interfaces are widely used in APIs for typechecking or runtime behavior decisions. 📢 Want More Java Interview Questions? Subscribe for 75+ tricky Java interview questions to help you ace your next technical interview! 🔔 Turn on notifications so you don’t miss a single video from this series! JavaInterview EmptyClass JavaTrickyQuestions ObjectOrientedJava JavaConcepts Would you like me to prepare a video on “Marker Interfaces vs Marker Classes” next? That pairs perfectly with this topic! 🚀