Computer scienceProgramming languagesJavaCode organizationObject-oriented programmingClasses and objectsClasses and members

Multiple constructors

Movie

Report a typo

You are given a class named Movie. Write two constructors for the class.

The first constructor should take three arguments (title, desc, year) and initialize the corresponding fields.

The second one should take only two arguments (title, year) and initialize title and year. In this case, the field desc should have a value "empty".

Use the provided template, do not change it.

Write a program in Java 17
class Movie {
private String title;
private String desc;
private int year;

// write two constructors here

public String getTitle() {
return title;
}

public String getDesc() {
return desc;
}

public int getYear() {
return year;
}
}
___

Create a free account to access the full topic