Solutions for EBK OBJECTS FIRST WITH JAVA
Problem 1E:
Create a TicketMachine object on the object bench and take a look at its methods. You should see the...Problem 5E:
Create another ticket machine for tickets of a different price; remember that you have to supply...Problem 7E:
Does it matter whether we write publicclassTicketMachineorclasspublicTicketMachine in the outer...Problem 9E:
Put back the word public, and then check whether it is possible to leave out the word class by...Problem 10E:
From your earlier experimentation with the ticket machine objects within BlueJ, you can probably...Problem 15E:
In the following field declaration from the TicketMachine class private int price; does it matter...Problem 19E:
How many parameters does the following constructor have, and what are their types?
public Book...Problem 21E:
Suppose that the class Pet has a field called name that is of the type String. Write an assignment...Problem 22E:
Challenge exercise The following object creation will result in the constructor of the Date class...Problem 23E:
Compare the header and body of the getBalance method with the header and body of the getPrice...Problem 24E:
If a call to getPrice can be characterized as "What do tickets cost?" how would you characterize a...Problem 25E:
If the name of getBalance is changed to getAmount, does the return statement in the body of the...Problem 27E:
Try removing the return statement from the body of getPrice. What error message do you see now when...Problem 28E:
Compare the method headers of getPrice and printTicket in Code 2.1. Apart from their names, what is...Problem 29E:
Do the insertMoney and printTicket methods have return statements? Why do you think this might be?...Problem 30E:
Create a ticket machine with a ticket price of your choosing. Before doing anything else, call the...Problem 31E:
How can we tell from just its header that setPrice is a method and not a constructor?
public void...Problem 32E:
Complete the body of the setPrice method so that it assigns the value of its parameter to the price...Problem 36E:
Write down exactly what will be printed by the following statement: System. out. Println ("My cat...Problem 37E:
Add a method called prompt to the TicketMachine class. This should have a void return type and take...Problem 39E:
What about the following version?
Problem 41E:
Add a showPrice method to the TicketMachine class. This should have a void return type and take no...Problem 42E:
Create two ticket machines with differently priced tickets. Do calls to their showPrice methods show...Problem 43E:
Modify the constructor of TicketMachine so that it no longer has a parameter. Instead, the price of...Problem 44E:
Give the class two constructors. One should take a single parameter that specifies the price, and...Problem 45E:
Implement a method, empty, that simulates the effect of removing all money from the machine. This...Problem 47E:
Predict what you think will happen if you change the test in insertMoney to use the greater-than or...Problem 48E:
Rewrite the if-else statement so that the method still behaves correctly but the error message is...Problem 50E:
In this version of printTicket, we also do something slightly different with the total and balance...Problem 51E:
Is it possible to remove the else part of the if-statement in the printTicket method (i.e., remove...Problem 52E:
After a ticket has been printed, could the value in the balance field ever be set to a negative...Problem 53E:
So far, we have introduced you to two arithmetic operators, that can be used in arithmetic...Problem 54E:
Write an assignment statement that will store the result of multiplying two variables, price and...Problem 55E:
Write an assignment statement that will divide the value in total by the value in count and store...Problem 57E:
Modify your answer to the previous exercise so that the message includes the value of your budget if...Problem 58E:
Why does the following version of refundBalance not give the same results as the original?...Problem 59E:
What happens if you try to compile the TIcketMachine class with the following version of...Problem 60E:
What is wrong with the following version of the constructor of TIcketMachine?
Try out this...Problem 61E:
Add a new method, emptyMachine, that is designed to simulate emptying the machine of money, it...Problem 62E:
Rewrite the printTicket method so that it declares a local variable, amountLeftloPay. This should...Problem 63E:
Challenge exercise Suppose we wished a single TicketMachine object to be able to issue tickets of...Problem 64E:
List the name and return type of this method:
Problem 66E:
Write out the outer wrapping of a class called Person. Remember to include the curly brackets that...Problem 67E:
Write out definitions for the following fields:
Problem 68E:
Write out a constructor for a class called Module. The constructor should take a single parameter of...Problem 71E:
Write an accessor method called getName that returns the value of a field called name, whose type is...Problem 72E:
Write a mutator method called setAge that takes a single parameter of type int and sets the value of...Problem 73E:
Write a method called printDetails for a class that has a field of type String called name. The...Problem 74E:
Draw a picture of the form shown in Figure 2.3, representing the initial state of a Student object...Problem 76E:
Create a Student with name "djb" and id "859012". What happens when getLoginName is called on this...Problem 78E:
Challenge exercise Modify the getLoginName method of Student so that it always generates a login...Problem 79E:
Consider the following expressions. Try to predict their results, and then type them in the Code Pad...Problem 80E:
Open the Code Pad in the better-ticket-machine project. Type the following in the Code Pad:
Take...Problem 81E:
Now add the following in the Code Pad: TicketMachinet2=t1; What would you expect a call to...Problem 82E:
Add the following: t1.InsertMoney500; What would you expect the following to return? Think carefully...Problem 85E:
Add a field, pages, to the Book class to store the number of pages. This should be of type int, and...Problem 87E:
Add a method, printDetails, to the Book class. This should print details of the author, title, and...Problem 88E:
Add a further field, refNumber, to the Book class. This field can store a reference number for a...Problem 89E:
Modify your printDetai 1 s method to include printing the reference number. However, the method...Browse All Chapters of This Textbook
Chapter 1 - Objects And ClassesChapter 2 - Understanding Class DefinitionsChapter 3 - Object InteractionChapter 4 - Grouping ObjectsChapter 6 - More-sophisticated BehaviorChapter 7 - Fixed-size Collections—arraysChapter 8 - Designing ClassesChapter 9 - Weil-behaved ObjectsChapter 10 - Improving Structure With InheritanceChapter 11 - More About Inheritance
Book Details
This is the eBook of the printed book and may not include any media, website access codes, or print supplements that may come packaged with the bound book. A Modern Approach to Functional Programming Objects First with Java: A Practical Introduction is an
Sample Solutions for this Textbook
We offer sample solutions for EBK OBJECTS FIRST WITH JAVA homework problems. See examples below:
Given: The class names such as Circle, Square, Triangle, Person, and Canvas. To find:Â The possible...Chapter 2, Problem 1EGiven: The lab-classes project and the object of LabClass as well as Student and three students are...Given: The project name music-organizer-v1 and the class name MusicOrganizer. To find: The way to...Given: The weblog-analyzer project with LogAnalyzer class, analyzeHourlyDataas well as...Explanation: Java allows using the JUnit test framework to write and execute automated tests. It...Given: The network project version and the display method is in the Post class. To find: The display...
More Editions of This Book
Corresponding editions of this textbook are also available below:
Objects First With Java: A Practical Introduction Using Bluej (5th Edition)
5th Edition
ISBN: 9780132492669
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
6th Edition
ISBN: 9780134477367
Objects First With Java: A Practical Introduction Using Bluej, Global Edition
6th Edition
ISBN: 9781292159041
EBK OBJECTS FIRST WITH JAVA
6th Edition
ISBN: 8220102955318
Objects First With Java: A Practical Introduction Using Bluej.
5th Edition
ISBN: 9780132835541
Objects First With Java: A Practical Introduction Using Bluej (4th Edition)
4th Edition
ISBN: 9780136060864
Related Computer Science Textbooks with Solutions
Still sussing out bartleby
Check out a sample textbook solution.