Quiz5_2010_sol - } } Which of the following Java statements...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
University of Ottawa Student name ………………. .………. .. School of IT and Engineering Student no . …………….………. .……. . ITI 1120 Quiz 5 Q1. [2 marks] Given the following Java class: public class Book { private String title; public String author; private int numPages; public Book(String title, String author, int n) { this.title = title; this.author = author; numPages = n; } public int getNumPages() { return numPages; } public void setNumPages(int n) { numPages = n;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } } Which of the following Java statements gives a compilation error? Circle only one answer. Answer: a. Book b1 = new Book("Harry Potter", "J.K. Rowling", 500); b1.author = "Joanne Rowling"; b. Book b1 = new Book("Harry Potter", "J.K. Rowling", 500); b1.title = "Harry Potter and the Half-Blood Prince"; c. Book b1 = new Book("Harry Potter", "J.K. Rowling", 500); int n = b1.getNumPages(); d. Book b1 = new Book("Harry Potter", "J.K. Rowling", 500); b1.setNumPages(600);...
View Full Document

Ask a homework question - tutors are online