Java Abstraction, Final, Static, and Interface Usage
Abstract Clases in Java \\nAbstract classes in Java are classes that cannot be instantiated on their own and must be inherited by other classes. They can contain both abstract methods (which do not have an implementation and must be overridden by subclasses) and concrete methods (with implementations).\\nExample:\\njava\n// Base abstract class\AbstractCreature {\\\n public abstract void consumeFood();\\\n}\\\n// Subclass implementing the abstract method\\\nclass Wolf extends AbstractCreature {\\\n @Override\\\n public void consumeFood() {\\\n System.out.println("Wolf eats meat");\\\n }\\\n}\\\n// Another subclass implementing the abstract method\\\nclass Rabbit extends AbstractCreature {\\\n @Override\\\n public void consumeFood() {\\\n System.out.println("Rabbit eats carrots");\\\n }\\\n}\\\n// Test class to demonstrate usage\\\npublic class AnimalTest {\\\n public static void main(String[] args) {\\\n AbstractCreature wolf = new Wolf();\\\n wolf.consumeFood();\\\n AbstractCreature rabbit = new Rabbit();\\\n rabbit.consumeFood();\\\n }\\\n}\\\n\\n### Final Keyword in Java \\nThe final keyword is used to denote that something is immutable. It can be applied to classes, methods, variables, and parameters.\\n- Final Class: Cannot be subclassed.\\n- Final Method: Cannot be overridden by subclasses.\\n- Final Variable: Once assigned, its value cannot be changed.\\nExample:\\njava\nfinal class ImmutableClass {\\\n final int fixedValue = 10;\\\n}\\\n\\n### Static Keyword in Java \\nThe static keyword allows variables and methods to belong to the class rather than instances of the class.\\n- Static Variables: Shared among all instances of the class.\\n- Static Methods: Can be called without creating an instance of the class.\\nExample:\\njava\nclass Company {\\\n static String department = "Engineering";\\\n static void changeDepartment(String newDept) {\\\n department = newDept;\\\n }\\\n}\\\n\\n### Interfaces in Java \\nInterfaces define a contract for what a class can do, without specifying how it does it. A class can implement multiple interfaces.\\nExample:\\njava\ninterface Vehicle {\\\n void startEngine();\\\n void stopEngine();\\\n}\\\nclass Car implements Vehicle {\\\n @Override\\\n public void startEngine() {\\\n System.out.println("Car engine started");\\\n }\\\n @Override\\\n public void stopEngine() {\\\n System.out.println("Car engine stopped");\\\n }\\\n}\\\n\\nInterfaces can also contain static methods and default methods from Java 8 onwards.\\nExample:\\njava\ninterface Vehicle {\\\n static void displayInfo() {\\\n System.out.println("This is a vehicle");\\\n }\\\n default void honk() {\\\n System.out.println("Beep beep");\\\n }\\\n}\\\n\\n