0% found this document useful (0 votes)
4 views

Java Object Class

The document outlines a series of programming tasks aimed at practicing object-oriented programming concepts in Java, including class creation, constructor overloading, method overriding, inheritance, encapsulation, and polymorphism. It also includes bonus conceptual questions about the principles of OOP, abstraction, and the differences between overriding and overloading. Each task is designed to reinforce understanding of key OOP principles through practical implementation.

Uploaded by

ankitmd001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Java Object Class

The document outlines a series of programming tasks aimed at practicing object-oriented programming concepts in Java, including class creation, constructor overloading, method overriding, inheritance, encapsulation, and polymorphism. It also includes bonus conceptual questions about the principles of OOP, abstraction, and the differences between overriding and overloading. Each task is designed to reinforce understanding of key OOP principles through practical implementation.

Uploaded by

ankitmd001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

🔷 1.

Create a class with two fields and a method to print them


Objective: Practice creating a class, constructor, and method.

🔷 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)

🔷 7. Create a Person class and extend it to a Teacher class


Concept: Inheritance

🔷 8. Show use of super keyword in inheritance


🔷 9. Create a method with the same name but different parameters
Concept: Method overloading (Compile-time 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

🔷 14. Demonstrate constructor chaining using this()


🔷 15. Show how to use final keyword with variable, method, and class
🔷 16. Create a BankAccount class and show encapsulation using private fields
🔷 17. Create a class with a method that returns this (method chaining)
🔷 18. Create a simple polymorphic program using a base class Vehicle and derived
classes Car, Bike
🔷 19. Show the use of instanceof keyword with base and derived classes
🔷 20. Difference between deep copy and shallow copy in Java (explain with example)
Bonus Conceptual Questions:
🧠 21. What are the 4 pillars of OOP? Explain with examples.
🧠 22. Why do we need abstraction in Java?
🧠 23. What is the difference between overriding and overloading?
🧠 24. Can we create an object of an abstract class? Why or why not?
🧠 25. What happens if we don’t override a method from the interface?

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy