Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
4th Edition
ISBN: 9780134787961
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 8, Problem 9MC
The Java Virtual Machine periodically performs this process, which automatically removes unreferenced objects from memory.
- a. memory cleansing
- b. memory deallocation
- c. garbage collection
- d. object expungement
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
The Java Virtual Machine periodically performs this process, which automatically removes unreferenced objects from memory.a. memory cleansingb. memory deallocationc. garbage collectiond. object expungement
JAVA PROGRAM ASAP
Please MODIFY THIS program ASAP BECAUSE it does not pass all the test caseswhen I upload it to hypergrade. It says 0 out of 4 passed. The program must pass the test case when uploaded to Hypergrade.
import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.Scanner;class Main { // Driver code public static void main(String[] args) { // scanner object used to take user input Scanner sc = new Scanner(System.in); // loop iterates until user enters "quit" or "QUIT" while (true) { System.out.print("Please enter the file name or type QUIT to exit:\n"); String fileName = sc.nextLine(); if (fileName.equalsIgnoreCase("QUIT")) { break; } try { // open file in read mode BufferedReader reader = new BufferedReader(new FileReader(fileName)); String line; StringBuilder result =…
JAVA Program ASAP
Modify this program below so it is a Filesorting.java program so it passes all the test cases when I upload it to Hypergrade. I have provided the failed test cases a screenshot.
import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.ArrayList;import java.util.Arrays;public class Main { public static void main(String[] args) { try { BufferedReader reader = new BufferedReader(new FileReader(getFileName())); String line; while ((line = reader.readLine()) != null) { processAndPrintSortedLine(line); } reader.close(); } catch (IOException e) { System.out.println("Error reading the file: " + e.getMessage()); } } private static String getFileName() { String fileName; java.util.Scanner scanner = new java.util.Scanner(System.in); do { System.out.println("Please enter the file name or type…
Chapter 8 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Ch. 8.1 - Prob. 8.1CPCh. 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
What does an object use its fields for?
Starting Out with Java: From Control Structures through Objects (6th Edition)
The text file babynames2012.txt, which is included in the source code for this book and is available online fro...
Problem Solving with C++ (9th Edition)
ArrayOperations Class Write a class name ArrayOperations with the following static methods: getTotal. This meth...
Starting Out with Java: Early Objects (6th Edition)
Private Sub Handles btnOutput.Click
End Sub
Introduction To Programming Using Visual Basic (11th Edition)
Explain why using model checking is sometimes a more cost-effective approach to verification than verifying a p...
Software Engineering (10th Edition)
When a file that already exists is opened in append mode, the file's existing contents are erased.
Starting Out with Programming Logic and Design (4th 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
- Hey I need to change this program below in a way that it saves and reads back the addresses utilizing Object Serialization. import java.io.*;import java.util.Scanner; public class AddressBook { //declaring the main function public static void main(String []args){ //creating the scanner object to get the input from the user Scanner sc = new Scanner(System.in); //printing the welcome message System.out.println("Welcome to Address Book!"); //asking the user to enter the details System.out.println("Enter last name, first name, phone number and email address: "); System.out.println("Enter EOF to end input"); //initialising the filewriter to write into the file FileWriter fileWriter; //initialising the bufferedwrite to write line into the file BufferedWriter writer; //initialising the filereader to read data from the file FileReader fileReader; //initialising the bufferedreader to…arrow_forwardIN JAVA Which is true? A. A program must import java.io.system to use System.out B. System.output.print() only outputs objects of type String C. The output of println() for an object reference includes all data stored in the object D. Data written to System.out are placed in a buffer and eventually outputarrow_forwardAnswer --import java.io.*; public class CallHelloPgm { public static void main(String args[]) { Process theProcess = null; BufferedReader inStream = null; System.out.println("CallHelloPgm.main() invoked"); // call the Hello class try { theProcess = Runtime.getRuntime().exec("java QIBMHello"); } catch(IOException e) { System.err.println("Error on exec() method"); e.printStackTrace(); } // read from the called program's standard output stream try { inStream = new BufferedReader( new InputStreamReader( theProcess.getInputStream() )); System.out.println(inStream.readLine()); } catch(IOException e) { System.err.println("Error on inStream.readLine()"); e.printStackTrace(); } } } .arrow_forward
- import java.util.Scanner; public class TowerOfHanoi { /** * Main class */ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter number of disk: "); int noOfDisks = scanner.nextInt(); System.out.println("Choose 3 rods roles(A, B, C) as (Initial, Final, Buffer): "); System.out.print("\tInitial Rod: "); char initialRod = scanner.next().charAt(0); System.out.print("\tFinal Rod: "); char finalRod = scanner.next().charAt(0); System.out.print("\tBuffer Rod: "); char bufferRod = scanner.next().charAt(0); towerOfHanoi(noOfDisks, initialRod, finalRod, bufferRod); } /** * * Recursion function */ static void towerOfHanoi(int noOfDisks, char initialRod, char finalRod, char bufferRod) { if (noOfDisks == 1) {…arrow_forwardAnswer the given question with a proper explanation and step-by-step solution. You are given the following code: import java.util.Scanner;public class Num {public static void main(String[] args) {int[][] myArray = new int[3][3];Scanner scanner = new Scanner(System.in); // Read in the numbers from the userSystem.out.println("Enter the elements of the matrix:");for (int i = 0; i < 3; i++) {for (int j = 0; j < 3; j++) {myArray[i][j] = scanner.nextInt();}}}} // Calculate the rowSum of each row using a for loopYour code goes here // Calculate the columnSum of each column using the for loopYour code goes herearrow_forwardimport java.util.Scanner; public class DebugSix3 { public static final int TIME_WASTER = 500; public static void main(String[] args) throws InterruptedException { Scanner input = new Scanner(System.in); System.out.print("Enter a number between 1 and 20 >> "); int num = input.nextInt(); if (num < 1 || num > 20) { System.out.println("Number out of range!"); return; } for (int i = num; i > 0; i--) { System.out.print(i + " "); Thread.sleep(TIME_WASTER); } System.out.println("Blastoff!"); } } The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. An example of the program is shown below: Enter a number between 1 and 20 >> 5 5 4 3 2 1 Blastoff! Depending on the value assigned to the…arrow_forward
- I need help fixing this Java profram shown below: import java.util.Scanner;import java.io.FileInputStream;import java.io.IOException; public class LabProgram { public static void main(String[] args) throws IOException { Scanner scnr = new Scanner(System.in); /* Type your code here. */ }}arrow_forwardCould you help me solve this problem? I am totally lost and honestly do not know what the question is asking. StatePopulations.java import java.util.Scanner;import java.io.FileInputStream;import java.io.IOException;import java.util.ArrayList; public class StatePopulations { public static ArrayList<StatePair<Integer, String>> fillArray1(ArrayList<StatePair<Integer, String>> statePairs, Scanner inFS) { StatePair<Integer, String> pair; int intValue; String stringValue; while (inFS.hasNextLine()) { intValue = inFS.nextInt(); stringValue = inFS.next(); pair = new StatePair<Integer, String> (intValue, stringValue); statePairs.add(pair); } return statePairs; } public static ArrayList<StatePair<String, String>> fillArray2(ArrayList<StatePair<String, String>> statePairs,…arrow_forwardPython 3 Temperature conversion between Fahrenheit and Celsius. Illustrates the use of numeric data fields. """ from breezypythongui import EasyFrame class TemperatureConverter(EasyFrame): """A termperature conversion program.""" def __init__(self): """Sets up the window and widgets.""" EasyFrame.__init__(self, title = "Temperature Converter") # self.addLabel (Label for Celsius) # self.celsiusField (Celsius field) # self.addLabel (Label for Fahrenheit) # self.fahrField (Fahrenheit field) # self.addButton (Celsius button) # self.addButton (Fahrenheit button) # The controller methods def computeFahr(self): """Inputs the Celsius degrees and outputs the Fahrenheit degrees.""" def computeCelsius(self): """Inputs the Fahrenheit degrees and outputs the Celsius degrees.""" def main(): """Instantiate and pop up the window."""…arrow_forward
- import java.io.File;import java.io.FileReader;import java.io.FileNotFoundException;import java.util.ArrayList;import java.util.Scanner; public class Client{Scanner sc = new Scanner(System.in);ArrayList <Student> students = new ArrayList<Student>();ArrayList <Student> courses = new ArrayList<Student>();// Method to read the file contents and stores it in// instance arraysvoid readStudents(){// Scanner class object declaredScanner readStuF = null;// try block beginstry{// Opens the file for readingreadStuF = new Scanner(new File("student.txt"));// Loops till end of the file to read recordswhile(readStuF.hasNextLine()){ String stu = readStuF.nextLine();String []eachStu = stu.split(" ");students.add(new Student(eachStu[0], eachStu[1],eachStu[2], Long.parseLong(eachStu[3]),Integer.parseInt(eachStu[4]), Integer.parseInt(eachStu[5]),Integer.parseInt(eachStu[6])));}// End of while loop }// End of try block// Catch block to handle file not found…arrow_forwardimport java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.Scanner;class MyException extends Exception{public MyException(String NegativeArraySizeException){System.out.println("The integer must be in between 1 and 20");}}public class arrayTwo {public static void main(String[]args){Scanner keyboard = new Scanner(System.in);System.out.println("How many integers do you have? (Max 20)");int[] num = new int[keyboard.nextInt()];if(num.length<=0 || num.length>20) {System.out.println("You must enter a number in between 1 and 20");}elsefor (int i = 0; i < num.length; i++) {System.out.println("Enter element for subscript " + i);num[i] = keyboard.nextInt();}System.out.println("Here are all of those numbers");for (int i = 0; i < num.length; i++) {System.out.println(num[i]);}}} attempted to use this code to fix the exception when a negative number is entered by the user, but it still gives back the exception. I would like to know how to…arrow_forwardimport java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.Scanner;class MyException extends Exception{public MyException(String NegativeArraySizeException){System.out.println("The integer must be in between 1 and 20");}}public class arrayTwo {public static void main(String[]args){Scanner keyboard = new Scanner(System.in);System.out.println("How many integers do you have? (Max 20)");int[] num = new int[keyboard.nextInt()];if(num.length<=0 || num.length>20) {System.out.println("You must enter a number in between 1 and 20");}elsefor (int i = 0; i < num.length; i++) {System.out.println("Enter element for subscript " + i);num[i] = keyboard.nextInt();}System.out.println("Here are all of those numbers");for (int i = 0; i < num.length; i++) {System.out.println(num[i]);}}} Need to figure out the code to get rid of the exception for inputting a negative as an array size.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher: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