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
Textbook Question
Chapter 8, Problem 10MC
If a class has this method, it is called automatically just before an instance of the class is destroyed by the Java Virtual Machine.
- a. finalize
- b. destroy
- c. remove
- d. housekeeper
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
If a class has this method, it is called automatically just before an instance of the class is destroyed by the Java Virtual Machine.a. finalizeb. destroyc. removed. housekeeper
Create a java class the performs the following commands in the listed order:
while (true) {
// Prompt the user to enter a command:
______________________________;
if (command is "a") {
// Prompt user for name and number:
______________________________;
// Create a phone number and store it in the record:
______________________________;
} else if (command is "f") {
// Prompt user for search key:
_______________________________;
// Search the database for records whose names begin with the search key:
_______________________________;
// Print these names and the corresponding phone numbers:
_______________________________;
} else if (command is "q") {
// Terminate program:
_______________________________;
} else {
// Display error message:
_______________________________;
}
}
Write the java code:
Create an class named Pet which contains 3 method named getName(), setName() & play(). Create a class named Cat that inherits the Pet class & contains a method named eat(). Create another class named Fish that also inherits the Pet class & overrides the Play() method. Write a test application that demonstrates each class's capabilities.
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...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Revise the definition of the class ListNode in Listing 12.4 so that it uses a type parameter instead of the typ...
Java: An Introduction to Problem Solving and Programming (8th Edition)
Explain what can be done with primary keys to eliminate key ripple effects as a database evolves.
Modern Database Management (12th Edition)
Assume there is a class named Animal, which overloads the and operators. In the following statement, assume c...
Starting Out with C++: Early Objects (9th Edition)
Write a statement that defines a file stream object named people. The object will be used for file output.
Starting Out with C++: Early Objects
Extreme programming expresses user requirements as stories, with each story written on a card. Discuss the adva...
Software Engineering (10th 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
- Write a java programme create a text based user interface class called WorkOutUI Create tow fields that will be accessible through the whole class A static constant field called ABBA to store the string "Agnetha#Benny#Bjorn#annafrid". A static field called an integer called totalPoints. Code a method Called processWorkOuts.The method must accept the name of the member of Abba whose text file must be processed.This method must be called from the main method. In the processWorkOuts Method: Display the name of the Abba Group whose file is being processed. add ".txt" to the file name sent as a parameter. instantiate a WorkOut object called workOut Using the constructor:+constructor(p:real, n:interger) ,send 0 for an initial points value and 0 as the initial numWorkOuts value. Open the text file and loop through the file extracting the start ,end,description and level fields from the file.Display an error message if the file cannot open. a) Instantiate a workout object using the…arrow_forwardThe BankAccount class models an account of a customer. A BankAccount has the followinginstance variables: A unique account id sequentially assigned when the Bank Account is created. A balance which represents the amount of money in the account A date created which is the date on which the account is created.The following methods are defined in the BankAccount class: Withdraw – subtract money from the balance Deposit – add money to the balance Inquiry on:o Balanceo Account ido Date createdThe SavingsAccount class models a bank account which is meant for long term savingsand earns interest. It inherits all the fields and methods of the BankAccount class. TheSavingsAccount class has an additional instance variable, interest rate. The interest rate is adecimal representing the rate at which the account earns interest. For example, an interestrate of .01 means that the account will earn 1% interest on its balance.The following additional methods are defined in the SavingsAccount…arrow_forwardThe BankAccount class models an account of a customer. A BankAccount has the followinginstance variables: A unique account id sequentially assigned when the Bank Account is created. A balance which represents the amount of money in the account A date created which is the date on which the account is created.The following methods are defined in the BankAccount class: Withdraw – subtract money from the balance Deposit – add money to the balance Inquiry on:o Balanceo Account ido Date createdThe SavingsAccount class models a bank account which is meant for long term savingsand earns interest. It inherits all the fields and methods of the BankAccount class. TheSavingsAccount class has an additional instance variable, interest rate. The interest rate is adecimal representing the rate at which the account earns interest. For example, an interestrate of .01 means that the account will earn 1% interest on its balance.The following additional methods are defined in the SavingsAccount…arrow_forward
- Create a Class Student in which we have three instance variables emp_name, emp_id, and Salary. Write getter and setters for each instance variable. Write another Display method that displays the record of Employee. In Main create five Employee’s Objects. Set their values as required and display as well. In the end Display top three employees with respect to Salary (Display those who have more Salary among all).arrow_forwardPlease answer these multiple choice questions 1) The new operator: allocates memory is used to create an object of a class associates an object with a variable that names it. All of the above. Answer: 2) A method that performs some action other than returning a value is called a __________ method. null void public private Answer: 3) The body of a method that returns a value must contain at least one _________ statement. void invocation thows return Answer: 4) A variable whose meaning is confined to an object of a class is called: instance variable local variable global variable none of the above Answer: 5) A variable whose meaning is confined to a method definition is called an/a instance variable local variable global variable none of the above Answer: 6) In Java, a block is delimited by: ( ) /* */ “ “ { } Answer: 7) In Java, call-by-value is only used with: objects primitive types this all of the above Answer: 8) The parameter this refers to instance variables local…arrow_forward# Write a Python class named Player. It will have instance attributes: # player_name, sports and average_score. # * Make a method called show_stat() that will display the player_name # and its average_score. # * Make a method called update_stat() that will accept an argument called # update_average_score of that player. # * Create at least two instances of the class and run the two methods.arrow_forward
- create a class in python with a constructor To create instances of the user defined class and practice applying them. Practice implementing loops. Part 1 Instructions:Create a class called BankAccount with the following variables: balancenameaccount_id Create 1 constructor for the class BankAccount (with or without parameters, your choice, but only 1): def __init_(self, name, account_id, balance)def __init_(self) Create the following methods in the BankAccount class: def viewAccountInfo() //prints all account information def withdraw(self, amount) //withdraws from the balance def deposit(self, amount) //deposits to the balance Your task after your class has been created: Create two objects, "personal" and "joint_account"with initial balances of:personal = $1000joint_account = $3000Use the constructor to create the objects. Create a program that prompts the user which account they would like to access personal or jointWhich account would you like to access? 1. Personal2. Joint…arrow_forwardCreate Java program Part one. Create a class called a BankSystem. Then, create the following instance variables, account_No, customer_Name, balance. create a method called openAccount has a no return type(void) that ask the user to enter enter a positive account number , name and balance. Then,create a method called AccountInfo to display the account details. Part two 1- create a method called depositMoney that ask the user to enter the amount to deposite. 2- create a method called withdrawMoney that ask the user to enter the amount to withdraw. 3- create a method called transferMoney that ask the user to enter the amount to transfer. 4- create a method called checktransfer boolean that return true or false. 5- create a method called checkBalance to chelck the account balance.arrow_forwardDesign a program using a console application in java, named studentMarksReport that will print the final result obtained by a student with the weighting of each module. Make use of a class named Student that contains variables to store the student number, test result, assignment result and exam. Create a constructor that accepts the student number, test result, assignment result and the exam result as parameters and create get methods for the variables (Use Scanner to get variable from the user). Create a subclass called Student_Report that extends the Student class. The Student_Report overrides all getter methods and the constructor from Students. Write code for the print_report method which calculates each assessment weighting as follows: Assessment Weighting Test 25% Assignment 25% Exam 50%arrow_forward
- class User:def __init__(self, first_name, last_name, user_id, last_login, password):self.first_name = first_nameself.last_name = last_nameself.user_id = user_idself.last_login = last_loginself.password = passworddef describe_user(self):print(f"Accessing user {self.user_id}:")print(f"{self.first_name} {self.last_name} last logged in on {self.last_login}")def greet_user(self):print(f"Welcome to the jungle {self.first_name} {self.last_name}, you gonna die")def new_login(self, month, day, year):if month < 1 or month > 12:print("That is not a valid month")returnif day < 1 or day > 31:print("That is not a valid day")returnif year < 0:print("That is not a valid year")returnmonths = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]month_name = months[month-1]self.last_login = f"{month_name} {day}, {year}" Hard-Code: # hard-coded callsjim =…arrow_forwardclass User:def __init__(self, first_name, last_name, user_id, last_login, password):self.first_name = first_nameself.last_name = last_nameself.user_id = user_idself.last_login = last_loginself.password = passworddef describe_user(self):print(f"Accessing user {self.user_id}:")print(f"{self.first_name} {self.last_name} last logged in on {self.last_login}")def greet_user(self):print(f"Welcome to the jungle {self.first_name} {self.last_name}, you gonna die") Hard-code # hard-coded calls jim = User(first_name='Jim',last_name='Bob',user_id=1000,last_login='June 12, 1998',password='password123')jim.describe_user()jim.greet_user()joe = User('Joe','Bob',1001,'July 4, 2001','babygirl')joe.greet_user()joe.describe_user()joe.new_login(2, 3, 2025)joe.describe_user()joe.new_login(15, 3, 2025)joe.new_login(2, 35, 2025)joe.new_login(2, 3, -55)arrow_forwardExercise 2 (BankAccount)Write a Java program that simulates primitive bank operations. To achieve this goal, followthese steps:1. Declare a static field amount with default value 5000.00.2. Declare another static field of type java.util.Scanner.3. Define a method displayMenu() that prints the available operations (Amount,Deposit, Withdraw, and Exit).4. Define a method getChoice() that calls displayMenu(), prompt the user to enterhis/her choice, reads and returns the choice (1, 2, 3, or 4).5. Define a method displayAmount() that display the current amount value.6. Define a method depositAmount() that takes an amount as parameter, adds it to thecurrent amount, and displays the new value of the amount.7. Define a method withdrawAmount() that takes an amount as parameter, removes itfrom the current amount, and displays the new value of the amount.8. Write a main() method that calls getChoice() repeatedly until the user enters thechoice 4 (exit), performs (calls) the right operation…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Memory Management Tutorial in Java | Java Stack vs Heap | Java Training | Edureka; Author: edureka!;https://www.youtube.com/watch?v=fM8yj93X80s;License: Standard YouTube License, CC-BY