Fixing the encapsulated Book class code

Report a typo

Let's say you're creating a simple Book class in Java. This class has only one instance variable 'title' which is private. You have also included a getter and setter method for 'title'. However, there are a few key pieces of syntax missing from this code. Your task is to fill the blanks in the code to make it a proper encapsulated class.

Fill in the gaps with the relevant elements
 class Book {
     String title;

    public String getTitle() {
         this.title;
    }

    public  setTitle(String title) {
        this.title = title;
    }
}
returnpublicvoidprivate
___

Create a free account to access the full topic