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 toString() 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.

02 Apr 2022
Answer :
Word Count : 244

Here's a Java program that defines a class named Car and another class named Engine as described in your question. The Car class has private members for registration number, model, and an instance of the Engine class. It also defines a constructor to initialize these members and overrides the toString() method to print the details of a car.

  

javaCopy __________ ___ ________ ______ _____.
____ _______ ____ _________ ________ ____ _______ __________ _______.
________ ______ _________ __________ ______ ___ _____ _________ ________.
____ _______ ____ ____ ___ ___ __________ _____ _______ ______ _______.
__________ ________ _____ ________ __________ ______ ____ _________ _____.
______ _______ _________ ______ ___ ____ ___ __________ __________ ______ ____ _________.
___ ___ _________ _____ ___ ___ ______.
___ ______ _______ _____ ___ _________ __________.
______ _____ _______ ______ ___ ______ ___ ______.
_________ ________ ______ ___ _______ ___.
_______ ____ ______ _____ ___ ________.
______ __________ __________ ____ ______ _____ ____.
______ ___ ________ _______ _______ ____ _____ ______ _______ ____.
____ __________ _____ ____ _____ _______ ___.
_________ ______ ______ ____ ___ _______ ______ __________ ____ ____ ___.
_______ __________ ____ _____ _______ _________ ___ ________.
________ ____ _______ _______ __________ _________ ____ ___.
_____ __________ __________ ______ ______ _______ ____ ______ ____ ____ ___.
__________ _____ _______ _________ _______ _____ __________ __________ _____ ___.
________ _______ _____ _______ ______ ____ ___ ________ _____ ______ _________ ___.
_________ ___ _________ ____ __________ _______ ___ _________ ___.
________.
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 Design a class named Car, having registration number, model and engine
🟢
WhatsApp Chat Fast live messaging
Email Us Business enquiries & support