Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
7th Edition
ISBN: 9780134802213
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 8.8, Problem 8.4CP
Program Plan Intro
“this” keyword:
“this” is nothing but a reference variable that refers to the current object. It can be used in many ways like:
- Using “this” keyword to refer the current class instance variables.
- “this()” can be used to invoke the current class constructor.
- “this” keyword can also be used to return the current class instance.
- “this” keyword can also be used as method parameter.
- “this” keyword is also used to invoke the current class method.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
public class BackAccount{public double Balance { set; get; }public void Deposit(double amount){Balance = Balance + amount;} }Transaction FeesTransaction TypeDeposit Withdrawal Check BalanceAmount0.25 % of the deposit amount 0.5 % of the withdrawal amount FreeQ.1.1Amount0.25 % of the deposit amount 0.5 % of the withdrawal amount FreeQ.1.1Using the code snippet above, complete the bank account functionality by adding Withdraw and CheckBalance methods. In your definition for the Withdraw method, check if the account has sufficient funds before making a withdrawal. Apply transaction fees as per the table above:
Q.1.2Using the transaction fees table and code snippet above, modify the Deposit method to include transaction fee charge.Q.1.3Generate a UML class diagram for the class definition above. Complete Q.1.1 and Q.1.2 before completing this question.Q.1.4Write a Unit Test class for the class used in Question 1 above. Name the unit test class “BankAccountTests”.Create a test method name…
Using classes and objects, create a program that will show method overloading
Complete the following code for a method that returns true if there is at least one element with a year level that matches a specified ????????????? ???? in an array of objects of the described ??????? class.
public boolean practice(student[] aArray, int yearLevelToSearch) { boolean found = false; for (int x = 0; x < aArray.length && !found; x++) { if (_____) { ______; } } }
}}
Chapter 8 Solutions
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Ch. 8.1 - What is the difference between an instance field...Ch. 8.1 - Prob. 8.2CPCh. 8.1 - Describe the limitation of static methods.Ch. 8.8 - Prob. 8.4CPCh. 8.9 - Look at the following statement, which declares an...Ch. 8.9 - Assume that the following enumerated data type has...Ch. 8.9 - Prob. 8.7CPCh. 8 - This type of method cannot access any non-static...Ch. 8 - Prob. 2MCCh. 8 - If you write this method for a class, Java will...
Ch. 8 - Making an instance of one class a field in another...Ch. 8 - This is the name of a reference variable that is...Ch. 8 - This enum method returns the position of an enum...Ch. 8 - Assuming the following declaration exists: enum...Ch. 8 - You cannot use the fully qualified name of an enum...Ch. 8 - The Java Virtual Machine periodically performs...Ch. 8 - If a class has this method, it is called...Ch. 8 - CRC stands for a. Class, Return value, Composition...Ch. 8 - True or False: A static member method may refer to...Ch. 8 - True or False: All static member variables are...Ch. 8 - Prob. 14TFCh. 8 - Prob. 15TFCh. 8 - Prob. 16TFCh. 8 - True or False: Enumerated data types are actually...Ch. 8 - True or False: enum constants have a toString...Ch. 8 - public class MyClass { private int x; private...Ch. 8 - Assume the following declaration exists : enum...Ch. 8 - Consider the following class declaration: public...Ch. 8 - Consider the following class declaration: public...Ch. 8 - A pet store sells dogs, cats, birds, and hamsters....Ch. 8 - Prob. 1SACh. 8 - Prob. 2SACh. 8 - Prob. 3SACh. 8 - Even if you do not write an equals method for a...Ch. 8 - A has a relationship can exist between classes....Ch. 8 - Prob. 6SACh. 8 - Is it advisable or not advisable to write a method...Ch. 8 - Prob. 8SACh. 8 - Look at the following declaration: enum Color {...Ch. 8 - Assuming the following enum declaration exists:...Ch. 8 - Under what circumstances does an object become a...Ch. 8 - Area Class Write a class that has three overloaded...Ch. 8 - BankAccount Class Copy Constructor Add a copy...Ch. 8 - Carpet Calculator The Westfield Carpet Company has...Ch. 8 - LandTract Class Make a LandTract class that has...Ch. 8 - Month Class Write a class named Month. The class...Ch. 8 - CashRegister Class Write a CashRegister class that...Ch. 8 - Sales Receipt File Modify the program you wrote in...Ch. 8 - Parking Ticket Simulator For this assignment you...Ch. 8 - Geometry Calculator Design a Geometry class with...Ch. 8 - Car Instrument Simulator For this assignment, you...Ch. 8 - First to One Game This game is meant for two or...Ch. 8 - Heads or TaiLs Game This game is meant for two or...
Knowledge Booster
Similar questions
- Look through the method header below, then, as an example, write a call to the method.an internal void ShowValue()arrow_forwardFill in the parameters in the second method header for the overloaded method printCourse(). The number, type, and order of the method parameters are indicated in the method call from main(). Ex: If the input is 82 Ethics, then the output is: Ethics grade: 82 Immunology grade: 87 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 System.out.println(courseName+" grade: "+grade); } publicstaticvoidprintCourse(/* Your code goes here */) { System.out.println("Immunology grade: "+inputGrade); } publicstaticvoidmain(String[] args) { Scannerscnr=newScanner(System.in); intgrade; StringcourseName; grade=scnr.nextInt(); courseName=scnr.next(); printCourse(grade, courseName); printCourse(87); // Overloaded method called } }arrow_forwardPlease in pyth coding with correct indentation 4a) Given that you have a Liquid class that can be initialized with any amount of gallons, liters, ounces, etc, write the first line of the method that will allow you to add together two Liquid objects using operator overloading. Again, write ONLY the first line (method definition) – you do NOT have to write the entire method. 4b) Given that you have L1 and L2 which are instances of the Liquid class, write a line of code that uses operator overloading to add them together and assign the result to L3.arrow_forward
- If you don't decalre a method as public or private, would the method be defaulted to public, private or something else? Here's a portion of my code that ties to this question:static int HCPTracker(ListInterface<Card> hand) { //Method detects if a hand contains an Ace, King, Queen, or Jack int HCPCount = 0; Card aceRef = new Card(Rank.Ace,null,null); //Allows the method to detect Aces, Kings, Queens, and/or Jacks Card kingRef = new Card(Rank.King,null,null); Card queenRef = new Card(Rank.Queen,null,null); Card jackRef = new Card(Rank.Jack,null,null);arrow_forwardHi, this isn't the static method of doing this. Could you please do the static method?arrow_forwardWhat will be returned from the following method? public double testing ( ) { double a = 9.5 + 9.3; return a; }arrow_forward
- Analyze the following class, then choose the correct returnValueType for the method average. void int String doublearrow_forwardThe following technique is used in a game of chess: canMoveTo(int x, int y), boolean. A method in the Piece class returns if the piece may travel to position (x, y). Describe how you would put this method to the test.arrow_forwardProvide answer in C#public class BackAccount{public double Balance { set; get; }public void Deposit(double amount){Balance = Balance + amount;} }Transaction FeesTransaction TypeDeposit Withdrawal Check BalanceAmount0.25 % of the deposit amount 0.5 % of the withdrawal amount FreeUsing the code snippet above, complete the bank account functionality by adding Withdraw and CheckBalance methods. In your definition for the Withdraw method, check if the account has sufficient funds before making a withdrawal. Apply transaction fees as per the table above:arrow_forward
- Examine the method header below, then write a call to the method as an example.a personal void ShowValue()arrow_forwardin class Song, write the calculation in method getEstEarnings of class Song to evaluate estimated earnings. Note that while in the real world, other methods would be used to estimate earnings, in this simplified model, the estimated earnings will be the length of the title, multiplied by the a value extracted by the ministry using the method getSongPartEst(hint.. the singer keeps a reference to the ministry. You can observe how the reference is used in method getClaimableEarnings). public int getEstEarnings() { return 0;//Q2. Perform this calculation } public int getClaimableEarnings() { int est = getEstEarnings(); if (est > singer.getMinistry().getMinClaimable()) return est; else return 0; }arrow_forwardIn Java, Use the Phone class as a baseline, and write a method isUSA. It should return true if the country code is 1 and false otherwise. Also expanding the Phone class, write a method that determines the location of an area code. It should return the name of the area code's city. For example, if cc = 1 and area code = 510 East Bay Area, 650 SF Peninsula, 415 San Francisco, 408 South Bay Area. For this assignment, use literal strings as return values.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,