Java Object Class
Java Object Class
🔷 2. Create a Student class with fields: name, roll number, and grade. Print their
details using a method.
🔷 3. Demonstrate constructor overloading
Hint: Create multiple constructors in a class with different parameters.
🔷 4. Create a method that calculates the area of a rectangle using this keyword
🔷 5. Show how to use static keyword for a variable and method
Task: Create a counter that increments every time an object is created.
🔷 6. Create a class Car with method startEngine() and another class ElectricCar
that overrides it
Concept: Method overriding (Runtime Polymorphism)
🔷 10. Create an abstract class Shape with an abstract method area() and extend it
in Circle and Rectangle
🔷 11. Create an interface Animal with method makeSound() and implement it in Dog
and Cat
🔷 12. Difference between abstract class and interface – explain with code
🔷 13. Create a class with private variables and use getters and setters
Concept: Encapsulation