About 550 results
Open links in new tab
  1. Creating a car class in java - Stack Overflow

    Sep 29, 2014 · In class Car, you have a constructor that has 4 parameters. However in the main class, you create a Car with 0 or 3 parameters. In other to run the code, you have to add 2 more constructor, one with 0 parameter, and one with 3 parameters.

  2. Java Classes and Objects - W3Schools

    Everything in Java is associated with classes and objects, along with its attributes and methods. For example: in real life, a car is an object. The car has attributes, such as weight and color, and methods, such as drive and brake. A Class is like an object constructor, or a "blueprint" for creating objects.

  3. Creating Car Class in Java - java problems

    Design and implement a class called Car that contains instance data that represents the make, model, and year of the car. Define the Car constructor to initialize these values. Include getter and setter methods for all instance data, and a toString method that …

  4. Vehicle, Car, and Truck Classes in Java - Display Details

    Apr 28, 2025 · Write a Java program to create a class called "Vehicle" with attributes for make, model, and year. Create subclasses "Car" and "Truck" that add specific attributes like trunk size for cars and payload capacity for trucks.

  5. Chapter[2]: Understanding Java Object-Oriented Programming …

    Nov 22, 2024 · Creating a Car class in Java is a great way to practice object-oriented programming. It lets us model real-world objects with attributes and behaviors, making our code more structured,...

  6. Classes and Objects in Java - GeeksforGeeks

    Mar 27, 2025 · Objects can be created many times as per the requirement. An example of class can be a car. A class in Java is a set of objects that share common characteristics and common properties. It is a user-defined blueprint or prototype from which objects are created. For example, Student is a class while a particular student named Ravi is an object.

  7. Java Classes and Objects - Baeldung

    Jan 8, 2024 · Objects of a class are called instances, and we create and initialize them with constructors: Car focus = new Car("Ford", "Focus", "red"); Car auris = new Car("Toyota", "Auris", "blue"); Car golf = new Car("Volkswagen", "Golf", "green");

  8. Create a Car class with constructor - Java Object Oriented Design

    The car class has three field: int speed; float temperature; Car(String inStatus, int inSpeed, float inTemperature) { status = inStatus; speed = inSpeed; temperature = inTemperature; void checkTemperature() { if (temperature < -80) { status = "returning home"; speed = 5; void showAttributes() { System.out.println("Status: " + status);

  9. java - Car class with acceleration and braking - Stack Overflow

    Nov 22, 2015 · Write a Driver class, the DrivingSimulation class, which does the following: Prompt the user for the yearModel, make, and speed values of a car.

  10. Chapter[6]: Understanding Java Classes and Keywords with Simple Car

    Nov 28, 2024 · A class in Java is the foundation for creating objects. Imagine you’re designing a Car class. It’s a template for creating individual car objects, each with its unique details and actions.

Refresh