Create a Java class named Book with instance variables title, author, ISBN, and
ID: 3806104 • Letter: C
Question
Create a Java class named Book with instance variables title, author, ISBN, and year Published. Include Java doc style comments to describe your interface. Such a class would normally have methods, but you are not required to supply any methods. Add and matador methods to the Book class created in question #13. Add a constructor and a copy constructor to the Book class created in question #13. Write a Java method that takes an integer array as a formal parameter and returns the sum of integers contained within the array. Declare and create a 10 times 10 multidimensional array of doubles.Explanation / Answer
Question 20, 21 & 22:
public class Book {
private String title;
private String author;
private int isbn;
private int yearPublished;
Book(String title, String author, int isbn,int yearPublished){
this.title = title;
this.author = author;
this.isbn = isbn;
this.yearPublished = yearPublished;
}
public Book(Book b){
this.title = b.title;
this.author = b.author;
this.isbn = b.isbn;
this.yearPublished = b.yearPublished;
}
public int getYearPublished() {
return yearPublished;
}
public void setYearPublished(int yearPublished) {
this.yearPublished = yearPublished;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public int getIsbn() {
return isbn;
}
public void setIsbn(int isbn) {
this.isbn = isbn;
}
public void display(){
System.out.println("Title : "+title+" Author : "+author+" ISBN : "+isbn);
}
}
Question 23
public int sumArray(int a[] ){
int sum = 0;
for(int i=0; i<a.length; i++) {
sum = sum + a[i];
}
return sum;
}
Question 24
Answer: double array[][]= new double[10][10];