Mark As Completed Discussion

Are you sure you're getting this? Click the correct answer from the options.

A beginner Java programmer created an immutable object, but it is not functioning correctly. What is wrong with their code? (Choose from options below)

SNIPPET
1public class Car {
2private final String model;
3private String registrationNum;
4
5Car (final String model) {
6    this.model = model;
7}
8
9public final String printModel() {
10    System.out.println(this.model);
11}

Click the option that best answers the question.

  • Missing `final` keyword in class name
  • Some data members not declared as `final`
  • Missing `set` method
  • All of the above