discussion Java ( NEED IT TODAY)

memzr1989

 

Giving the following code snippet:

Discuss the reasons of using private access specifier in some places of the code and public in other places. Additionally, discuss how can you test this code.

public class Book

{

      private String bookName;

      private int ed;

      private String author;

      public Book (String n, int e, String a)

      {

           bookName = n;

           ed = e;

           author = a;

      }

      /**

       * Gets the book name.

       * @return the book name.

       */

      public String getBookName()

      {

           return bookName;

      }

      /**

       * Gets the book edition.

       * @return the book edition.

       */

      public int getBookEd()

      {

           return ed;

      }

      /**

       * Gets the book author.

       * @return the book author.

       */

      public String getAuthor()

      {

           return author;

      }

      /**

       * Prints the Book details.

       */

      public void printBookDetails()

      {

           System.out.println("Book Name:" + getBookName() );

           System.out.println("Book edition: " +  getBookEd() );

           System.out.println("Book Author: " + getAuthor() );

      }

}

    • 7 years ago
    • 7
    Answer(3)

    Purchase the answer to view it

    • PublicandPrivateAccessSpecifiers.docx

    Purchase the answer to view it

    NOT RATED

      Purchase the answer to view it

      NOT RATED
      • java-book-modifiers.zip