Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
6th Edition
ISBN: 9780134477367
Author: David J. Barnes, Michael Kolling
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 2, Problem 25E
If the name of getBalance is changed to getAmount, does the return statement in the body of the method also need to be changed for the code to compile? Try it out within BlueJ. What does this tell you about the name of an accessor method and the name of the field associated with it?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Can you guess what types some of the Book class’s fields might be, from the parameters in its constructor? Can you assume anything about the names of its fields?
Examine the getBalance method's header and body, and then evaluate how they stack up against those of the getPrice method. I'm confused as to the differences between the two.
Write out what you think the outer wrappers of the Student and LabClass classes might look like; do not worry about the inner part.
Chapter 2 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Ch. 2 - Create a TicketMachine object on the object bench...Ch. 2 - What value is returned if you get the machine's...Ch. 2 - Prob. 3ECh. 2 - Prob. 4ECh. 2 - Create another ticket machine for tickets of a...Ch. 2 - Prob. 6ECh. 2 - Does it matter whether we write...Ch. 2 - Prob. 8ECh. 2 - Put back the word public, and then check whether...Ch. 2 - From your earlier experimentation with the ticket...
Ch. 2 - Prob. 11ECh. 2 - Prob. 12ECh. 2 - Prob. 13ECh. 2 - Prob. 14ECh. 2 - In the following field declaration from the...Ch. 2 - Prob. 16ECh. 2 - Prob. 17ECh. 2 - To what class does the following constructor...Ch. 2 - How many parameters does the following constructor...Ch. 2 - Prob. 20ECh. 2 - Suppose that the class Pet has a field called name...Ch. 2 - Challenge exercise The following object creation...Ch. 2 - Compare the header and body of the getBalance...Ch. 2 - If a call to getPrice can be characterized as...Ch. 2 - If the name of getBalance is changed to getAmount,...Ch. 2 - Prob. 26ECh. 2 - Try removing the return statement from the body of...Ch. 2 - Compare the method headers of getPrice and...Ch. 2 - Do the insertMoney and printTicket methods have...Ch. 2 - Create a ticket machine with a ticket price of...Ch. 2 - How can we tell from just its header that setPrice...Ch. 2 - Complete the body of the setPrice method so that...Ch. 2 - Prob. 33ECh. 2 - Is the increase method a mutator? If so, how could...Ch. 2 - Prob. 35ECh. 2 - Write down exactly what will be printed by the...Ch. 2 - Add a method called prompt to the TicketMachine...Ch. 2 - Prob. 38ECh. 2 - What about the following version?
Ch. 2 - Prob. 40ECh. 2 - Add a showPrice method to the TicketMachine class....Ch. 2 - Create two ticket machines with differently priced...Ch. 2 - Modify the constructor of TicketMachine so that it...Ch. 2 - Give the class two constructors. One should take a...Ch. 2 - Implement a method, empty, that simulates the...Ch. 2 - Prob. 46ECh. 2 - Predict what you think will happen if you change...Ch. 2 - Rewrite the if-else statement so that the method...Ch. 2 - Prob. 49ECh. 2 - In this version of printTicket, we also do...Ch. 2 - Is it possible to remove the else part of the...Ch. 2 - After a ticket has been printed, could the value...Ch. 2 - So far, we have introduced you to two arithmetic...Ch. 2 - Write an assignment statement that will store the...Ch. 2 - Write an assignment statement that will divide the...Ch. 2 - Prob. 56ECh. 2 - Modify your answer to the previous exercise so...Ch. 2 - Why does the following version of refundBalance...Ch. 2 - What happens if you try to compile the...Ch. 2 - What is wrong with the following version of the...Ch. 2 - Add a new method, emptyMachine, that is designed...Ch. 2 - Rewrite the printTicket method so that it declares...Ch. 2 - Challenge exercise Suppose we wished a single...Ch. 2 - List the name and return type of this method:
Ch. 2 - Prob. 65ECh. 2 - Write out the outer wrapping of a class called...Ch. 2 - Write out definitions for the following fields:
Ch. 2 - Write out a constructor for a class called Module....Ch. 2 - Prob. 69ECh. 2 - Correct the error in this method:...Ch. 2 - Write an accessor method called getName that...Ch. 2 - Write a mutator method called setAge that takes a...Ch. 2 - Write a method called printDetails for a class...Ch. 2 - Draw a picture of the form shown in Figure 2.3,...Ch. 2 - Prob. 75ECh. 2 - Create a Student with name "djb" and id "859012"....Ch. 2 - Prob. 77ECh. 2 - Challenge exercise Modify the getLoginName method...Ch. 2 - Consider the following expressions. Try to predict...Ch. 2 - Open the Code Pad in the better-ticket-machine...Ch. 2 - Now add the following in the Code Pad:...Ch. 2 - Add the following: t1.InsertMoney500; What would...Ch. 2 - Prob. 83ECh. 2 - Prob. 84ECh. 2 - Add a field, pages, to the Book class to store the...Ch. 2 - Are the Book objects you have implemented...Ch. 2 - Add a method, printDetails, to the Book class....Ch. 2 - Add a further field, refNumber, to the Book class....Ch. 2 - Modify your printDetai 1 s method to include...Ch. 2 - Prob. 90ECh. 2 - Add a further integer field, borrowed, to the Book...Ch. 2 - Prob. 92ECh. 2 - Prob. 93ECh. 2 - Prob. 94E
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
(Bar-Chart Printing Program) One interesting application of computers is to display graphs and bar charts. Writ...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Suppose you have two function definitions with the function declarations given in Self-Test Exercise 25. Which ...
Problem Solving with C++ (10th Edition)
Run the hello, world program on your system. Experiment with leaving out parts of the program, to see what erro...
C Programming Language
What is the output produced by the following? intnumber=10;while(number0)number=number2;if(number==4)continue;S...
Absolute Java (6th Edition)
(Find the smallest n such that n2 12,000) Use a while loop to find the smallest integer n such that n2 is grea...
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- It implies testing in a "BLACK Box." What different variants exist on this theme?arrow_forwardIs the increase method a mutator? If so, how could you demonstrate this?arrow_forwardIs it possible to infer, from the constructor arguments, the types of some of the Book class's fields? Can you hazard a guess as to what its various fields are called?arrow_forward
- Get to know about the proof-carrying code, a method in which the provider of mobile code provides an evidence of its security, and the user merely checks the proof rather than creating it (start with the work of Necula [Nec97]). What are the advantages and disadvantages of this approach to sandboxing? What features does it promise to have?arrow_forwardWrite a method that takes two string parameters, and tells whether the first is a substring of the second. You can't use framework methods that do this for you, such as indexOf(). In other words, you have to write the loops yourself. But, you can use the primitive methods such as charAt(). Also analyze the program's performance and state the big-O complexity of your method. Provide a screenshot of the code working.arrow_forwardCopy your previous class definition for RectangularSolid from the previous problem, including both methods. Provide mutators (setters) and accessors (getters) for each of the three parameters. Use the naming convention for these methods that is demonstrated in your textbook (i.e. do not use the property function or decorators). These methods should allow a program using your code to modify the parameter values after creation and to read individual parameter values.arrow_forward
- Just a few words on what a method is, and then we can move on to the three components.arrow_forwardThe Challenge: You are dealing with a lot of unfamiliar code and want to walk through it step by step. You've reached a call to the method do_the_funny_bird and want to know what it does, but you're not sure where it's defined. How to efficiently explore the code in such circumstances.arrow_forwardIterating over a collection of items is the job of the for construct's looping mechanism. So long as there are things to process, it will keep running forever. So, what do you make of this?arrow_forward
- This solution is unclear and does not answer my question. I am trying to add a main method to my code.arrow_forwardHow many different ways can you think of to indicate that a method has received incorrect parameter values or is otherwise unable to complete its task? Consider as many different sorts of applications as you can—for instance: those with a GUI; those with a textual interface and a human user; those with no sort of interactive user, such as software in a vehicle’s enginemanagement system; or software in embedded systems such as a cash machine.arrow_forwardCompare the header and body of the getBalance method with the header and body of the getPrice method. What are the differences between them?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Java Math Library; Author: Alex Lee;https://www.youtube.com/watch?v=ufegX5o8uc4;License: Standard YouTube License, CC-BY