Menu

(Solved) : Giving Following Code Snippet Discuss Reasons Using Private Access Specifier Places Code P Q34608936 . . .

Giving the following code snippet:

Discuss the reasons of using privateaccess specifier in some places of the code andpublic in other places. Additionally, discuss how can youtest this code.

public class Book

{

     privateStringbookName;

     privateinted;

     private String author;

    

     public Book (String n, int e, Stringa)

     {

          bookName = n;

           ed= e;

          author = a;

     }

    

     /**

     * Gets the book name.

     * @return the book name.

     */

     public String getBookName()

     {

          returnbookName;

     }

    

     /**

     * Gets the book edition.

     * @return the book edition.

     */

     publicintgetBookEd()

     {

          returned;

     }

    

     /**

     * 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() );

     }

}

* use MS Format

* be sure of answer

Expert Answer


Answer to Giving Following Code Snippet Discuss Reasons Using Private Access Specifier Places Code P Q34608936 . . .

OR