Question

Design a class named Car, having registration number, model and engine as its private members. Here engine is an object of a class called Engine with the private members: Chassis number and make. Define a suitable constructor of Car and override to String () Method to print the details of a car. Assume appropriate data types for the instance members of the classes. Write a Java program to test the above class. 

11 Mar 2023
Answer :
Word Count : 373

// Engine class
class Engine {
    private String chassisNumber;
    private String make;

    // Constructor for Engine class
    public Engine(String chassisNumber, String make) {
        this.chassisNumber = chassisNumber;
        this.make = make;
    }

    // Getter methods for Engine class
    public String getChassisNumber() {
        return chassisNumber;
    }

    public String getMake() {
        return make;
    }
}

// Car class
class Car {
    private String registrationNumber;
    private String model;
    private Engine engine;

    // Constructor for Car class
    public Car(String registrationNumber, String model, Engine engine) {
        this.registrationNumber

___ _________ _________ _________ ________ ___ ____ _____ _________ __________.
___ ________ _______ _________ ____.
________ _________ __________ _______ _______ ________ _________ ____ _____ ________.
________ _________ _____ __________ _________ _______ ____.
_____ __________ ________ _______ ________ ___ _________ ___ _____ ______ _____ _____.
_____ ___ ____ ________ _______ ______.
_________ ______ ______ __________ ____.
____ ____ _______ ________ ________ ________ ___ ____ ____ ___ __________.
_______ ______ _______ _______ _____ _____ ______ _____ _____ ______.
___ _________ _________ __________ _____ _____ ________ _________ ___ _____.
______ _________ _______ _________ _________ _____ ________ ________ _______ ____ ______ ______.
_____ ________ ________ _________ __________ _________ _______ _________ _____ ______ ___ _____.
_________ ________ ___ ________ _______ ________ ___ __________ ___ _______.
______ ________ ________ _____ _____ __________ ________ ________ ________.
___ _________ _______ _________ ________ _______ _____ ___ _____.
____ ________ _________ _________ ____.
__________ ______ _______ ______ ___ _______ _____ _________ ____ ___ ___.
______ ____ ____ ________ _________ ______ ___.
_________ ______ _______ _________ ______ ___ _____ ____ ______ ________ ___ _____.
____ ________ _______ ______ __________ ____.
___ _____ _________ _________ ________ _________ ____.
________ _______ _________ ___ _______.
____ _________ __________ ______ ____.
_______ ______ ____ ______ ________ ____ ___ __________ ______ ___ ______ ____.
____ __________ ______ ________ _____.
________ ________ _______ ____ _________ _______ ___ ________ _________ ________ ____.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU MLIL 7 2023 - Design a class named Car, having registration number, model and engine | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→