Question

Write a java program to demonstrate constructor overloading, method overloading and method overriding. Make necessary assumptions. 

13 Sep 2024
Answer :
Word Count : 636

Sure! Here’s a Java program demonstrating constructor overloading, method overloading, and method overriding. We’ll use a simple example involving a base class `Shape` and two derived classes `Circle` and `Rectangle`. Each class will illustrate these concepts.

```java
// Base class
class Shape {
    private String color;
    private int sides;

    // Constructor overloading
    public Shape() {
        this.color = "Unknown";
        this.sides = 0;
    }

    public Shape(String color) {
        this.color = color;
        this.sides = 0;
    }

    public Shape(String color, int sides) {
        this.color = color;
        this.sides = sides;
    }

    // Method overloading
    public void displayInfo() {
        ____ ____ ________ _____ _____ ___ ____.
___ _______ ________ ________ ___ ______ _________ _________ ___ __________ _______.
______ __________ _______ __________ __________ ____ _______ ___.
_____ _______ ________ _____ _________ _______.
___ ___ ___ _______ ___.
_______ __________ ______ ____ ________ ________.
______ _______ ____ _________ _______ ___ ___ _____ __________ ______ _________ ________.
_________ ___ _____ ______ ______ ______.
___ ___ ___ ____ ___ ______ _________ ________ ____ ________.
_______ _______ ________ _______ ______ __________ ______ ______ _________ ___ __________.
___ _______ __________ ______ ___ __________ _____.
____ ______ ______ ____ ____.
__________ _________ _________ ________ _____ _________ _______ ______ _____ __________ _______ ________.
_______ ____ __________ _______ ______.
__________ ___ ___ ________ ____ ________ _______ _____ ______ __________ ______ ______.
______ ____ __________ ________ ___ ____.
__________ ___ ____ ______ ______ _______ _____ ______ ___.
___ _____ _____ ______ ______ _______ _______ ____ ____.
_________ _________ _________ ___ _______ ____ _________ _______ ______ ____ _____.
________ ________ ____ _______ _____ _________ _____.
______ ______ __________ _____ ______.
___ _____ ________ _________ _________.
_____ _______ ___ __________ _________ __________ ____.
______ ______ _______ _________ ____ ___ ____ ________ ___ ________ __________.
________ __________ ________ _____ __________ _______ ___ ____ ________.
___ ____ ______ _________ _______ ______ ______ _____ ______.
_______ _____ _____ __________ ______ _____ __________ ______.
____ _______ ___ ____ ____ ____ _____ _________ _______ ______ __________.
___ ___ _____ ________ _________ ________ ______ _____ ___ _______ _________.
__________ _____ ______ ______ _______ ________ ___ _________ _____ ______ ________.
________ __________ _____ _____ _________ ____ __________ _________ _________ ________ ______ _____.
________ ________ _______ __________ _____ __________ ___ ____.
_______ ______ ___ ________ ___ ________ ______.
________ _________ ________ ________ ________ __________ ________.
_________ ______ _____ ____ ____ ____ ______ _____.
____ ____ _______ _______ _____ ___ ______ _________.
_____ ____ ___ ____ ______ ________ _________ ______ ____.
_________ ___ ________ _______ _________ _____ _____ _____ _____ ______ __________.
_______ ____ _____ ____ __________.
________ ________ ________ _________ ________ ______ _____ __________.
______ __________ _________ _______ ______ ________ ___ ______ __________ ____ _________.
_______ ___ _____ ____ ____ _____ _____ ______.
_________ _____ ___ _________ __________ _______ _________.
___ _________ ________ ___ __________ ____ __________ __________ ____ ______ __________ _________.
__________ ____ ____ ________ __________ __________ _____.
_______ _______ _________ ________ ________ ________.
__________ ___ _______ _______ ________ ___ _________ _________ ____.
________ ____ ____ ______ ___ ___ ___ _________ __________.
_______ __________ ________ ____ _____ ______ _________.
____ ___ _______ ___ ____ ________ _______ _____ ______ __________ ________ ______.
___ ___ ___ ____ ____ _______.
________ ___ _____ _________ ____ ______ ____ _____ _____.
_________ _____ ____ _______ ________ ___ ______ _______ ________ _______.
_________ __________ __________ __________ __________ ___ ___ ___ ____ ____.
________ ______ ___ _____ ______.
___ ______ ______ ________ _____ _____ ___ ________ ____ __________ _____ _____.
_____ ________.
Get Full Answer on WhatsApp

IGNOU NEWS
Assignment Submission Last Date Extended Till 30 June 2026 Click Here★★★IGNOU June 2026 TEE Date Sheet Released Click Here★★★
Top
📞
Call Support Instant phone assistance Write a java program to demonstrate constructor overloading, method ov
🟢
WhatsApp Chat Fast live messaging
Email Us Business enquiries & support