fork download
  1. public class Car {
  2. String carname;
  3. String model;
  4. String owner;
  5. Integer year;
  6.  
  7. // Constructor to initialize the Car object
  8. public Car(String carname, String model, String owner, Integer year) {
  9. this.carname = carname;
  10. this.model = model;
  11. this.owner = owner;
  12. this.year = year;
  13. }
  14.  
  15. // Method to display car details
  16. public void show() {
  17. System.debug('Car name: ' + this.carname);
  18. System.debug('Model name: ' + this.model);
  19. System.debug('Owner name: ' + this.owner);
  20. System.debug('Year: ' + this.year);
  21. }
  22. }
  23.  
  24. // Creating an instance of the Car class and initializing it
  25. Car c1 = new Car('Ford Ecosport', 'Diesel', 'Manan', 2024);
  26. c1.show();
  27.  
Success #stdin #stdout #stderr 0.02s 8972KB
stdin
Standard input is empty
stdout
Object: UndefinedObject error: did not understand #Car
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
UndefinedObject class(Object)>>doesNotUnderstand: #Car (SysExcept.st:1448)
UndefinedObject>>executeStatements (prog:1)
stderr
./prog:3: parse error, expected '}'