Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
11th Edition
ISBN: 9780134671710
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 17.6, Problem 17.6.2CP
Program Plan Intro
Serializable objects:
To serialize an object it needs to convert its state to a byte stream. After converting it into the byte stream it can be reverted back into a copy of the object. To serialize a java object, its class or any superclass should implement “java.io.serializable”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
I want to develop an application for Knight's Tour Chess Game in java where the board is an eight by eight - 2D array board. Each square should be 0 in the beginning and as the knight moves in L shaped moves. The application is developed to move the knight around the chessboard and then keep a counter that varies from 1 to 64. Record the latest count in each square the knight moves to. Test each potential move to see if the knight has already visited that square. Test every potential move to ensure that the knight does not land off the chessboard. I want to run the application with random initial position.
In Java, give an example of a method that requests Name input. Then show another method, in the same application, that searches an object array in an object class for duplicates and reports an error when there is one.
How would you utilize the second method with the first one?
In Java please
Chapter 17 Solutions
Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
Ch. 17.2 - What is a text file and what is a binary file? Can...Ch. 17.2 - How do you read or write text data in Java? What...Ch. 17.3 - Prob. 17.3.1CPCh. 17.3 - How is a Java character represented in the memory,...Ch. 17.3 - If you write the string ABC to an ASCII text file,...Ch. 17.3 - If you write the string 100 to an ASCII text file,...Ch. 17.3 - What is the encoding scheme for representing a...Ch. 17.4 - Prob. 17.4.1CPCh. 17.4 - Why should you always close streams? How do you...Ch. 17.4 - Prob. 17.4.3CP
Ch. 17.4 - Does FileInputStream/Fi1eOutputStream introduce...Ch. 17.4 - What will happen if you attempt to create an input...Ch. 17.4 - How do you append data to an existing text file...Ch. 17.4 - Prob. 17.4.7CPCh. 17.4 - What is written to a file using writeByte(91) on a...Ch. 17.4 - How do you check the end of a file in an input...Ch. 17.4 - What is wrong in the following code? Import...Ch. 17.4 - Suppose you run the following program on Windows...Ch. 17.4 - After the following program is finished, how many...Ch. 17.4 - For each of the following statements on a...Ch. 17.4 - What are the advantages of using buffered streams?...Ch. 17.5 - How does the program check if a file already...Ch. 17.5 - How does the program detect the end of the file...Ch. 17.5 - How does the program count the number of bytes...Ch. 17.6 - Prob. 17.6.1CPCh. 17.6 - Prob. 17.6.2CPCh. 17.6 - Is it true that any instance of...Ch. 17.6 - Prob. 17.6.4CPCh. 17.6 - Prob. 17.6.5CPCh. 17.6 - What will happen when you attempt to run the...Ch. 17.7 - Can RandomAccessFi1e streams read and write a data...Ch. 17.7 - Create a RandomAccessFi1e stream for the file...Ch. 17.7 - What happens if the file test.dat does not exist...Ch. 17 - (Create a text file) Write a program to create a...Ch. 17 - (Create a binary data file) Write a program to...Ch. 17 - (Sum all the integers in a binary data file)...Ch. 17 - (Convert a text file into UTF) Write a program...Ch. 17 - Prob. 17.5PECh. 17 - Prob. 17.6PECh. 17 - Prob. 17.7PECh. 17 - (Update count) Suppose that you wish to track how...Ch. 17 - (Address book) Write a program that stores,...Ch. 17 - (Split files) Suppose you want to back up a huge...Ch. 17 - (Split files GUI) Rewrite Exercise 17.10 with a...Ch. 17 - Prob. 17.12PECh. 17 - (Combine files GUI) Rewrite Exercise 17.12 with a...Ch. 17 - (Encrypt files) Encode the file by adding 5 to...Ch. 17 - (Decrypt files) Suppose a file is encrypted using...Ch. 17 - (Frequency of characters) Write a program that...Ch. 17 - (BitOutputStream) Implement a class named...Ch. 17 - (View bits) Write the following method that...Ch. 17 - (View hex) Write a program that prompts the user...Ch. 17 - (Hex editor) Write a GUI application that lets the...
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
- Can you implement the Student class using the concepts of encapsulation? A solution is placed in the "solution" section to help you, but we would suggest you try to solve it on your own first. You are given a Student class in the editor. Your task is to add two fields: ● String name ● String rollNumber and provide getter/setters for these fields: ● getName ● setName ● getRollNumber ● setRollNumber Implement this class according to the rules of encapsulation. Input # Checking all fields and getters/setters Output # Expecting perfectly defined fields and getter/setters. There is no need to add constructors in this class.arrow_forwardIN JAVA please! Rare Collection. We can make arrays of custom objects just like we’ve done with ints and strings. While it’s possible to make both 1D and 2D arrays of objects (and more), for this assignment we’ll start you out with just one dimensional arrays. Your parents have asked you to develop a program to help them organize the collection of rare CDs they currently have sitting in their car’s glove box. To do this, you will first create an AudioCD class. It should have the following private attributes. String cdTitle String[4] artists int releaseYear String genre float condition Your class should also have the following methods: Default Constructor: Initializes the five attributes to the following default values: ◦ cdTitle = “” ◦ artists = {“”, “”, “”, “”} ◦ releaseYear = 1980 ◦ genre = “” ◦ condition = 0.0 Overloaded Constructor: Initializes the five attributes based on values passed into the formal parameters ◦ If condition is less than 0.0 or greater than 5.0,…arrow_forwardThis is needed in java Given an array of doubles named heights, change the value at index 12 to 135.9.arrow_forward
- Answer the given question with a proper explanation and step-by-step solution. Write a method that takes in an array of Point2D objects, and then analyzes the dataset to find points that are close together. Be sure to review the Point2D API. In your method, if the distance between any pair of points is less than 10, display the distance and the (x,y)s of each point. For example, "The distance between (3,5) and (8,9) is 6.40312." The complete API for the Point2D ADT may be viewed at http://www.ime.usp.br/~pf/sedgewick-wayne/algs4/documentation/Point2D.htmlLinks to an external site.. Do not compare a point to itself! Try to write your program directly from the API - do not review the ADT's source code. (Don't worry too much about your answer compiling - focus on using an API from its documentation.) Your answer should include only the method you wrote, do not write a complete program.arrow_forwardContext: I made a program that allowed the user to play TOWERS OF HANOI. user can perid the amount of discs to play and do the movements. HANOI game: It consists of a game of 3 towers and discs. The objective is to pass the disks from a source tower to a destination tower. The problem I have is that the game always starts in Tower 1. I would like you to help me modify the method I have to START THE GAME: When I run it, it always starts in tower 1. I would like the method to start in the tower that the user says. also that he says which tower he wants to finish. Example: I want the game to start in tower 2 and end in tower 1 and validate that the game is over. I HAVE ALL THE GAME MADE. the problem lies in what has been said above. METHOD TO MODIFY SO that the user requests (ORIGIN Tower, DESTINATION Tower and validate if I win the game.) /// public static void Start_hanoi(){ // REQUEST NUMBER OF DISCS System.out.println("Write the number of disks to process: ");ndisk =…arrow_forwardIn Java: The CSV (or comma-separated values) format is commonly used for tabular data. Each table row is a line, with columns separated by commas. Items may be enclosed in quotation marks, and they must be if they contain commas or quotation marks. Quotation marks inside quoted fields are doubled. Here is a line with four fields:1729, San Francisco, "Hello, World", "He asked: ""Quo vadis?""" Implement a class CSVReader that reads a CSV file, and provide methodsint numberOfRows()int numberOfFields(int row)String field(int row, int column)arrow_forward
- Please answer the question in the screenshot. The language used is Java.arrow_forwardWhat happens when you try to perform 1.0/0.0 operation. Also Explain it in Javaarrow_forwardLet's say you have an integer array and a string array. You have to write asingle method printArray that can print all the elements of both arrays. Themethod should be able to accept both integer arrays or string arrays.(Do not use overloading, use generics).Name the file ArrayPrint.javaarrow_forward
- This question is in javaYou are walking along a hiking trail. On this hiking trail, there is elevation marker at every kilometer. The elevation information is represented in an array of integers. For example, if the elevation array is [100, 50, 20, 30, 50, 40], that means at kilometer 0, the elevation is 100 meters; at kilometer 1, the elevation is 50 meters; at kilometer 2, the elevation is 20 meters; at kilometer 3, the elevation is 30 meters; at kilometer 4, the elevation is 50 meters; at kilometer 5, the elevation is 40 meters. a) Write a method called dangerousDescent that determines whether there is a downhill section in the hiking trail with a slope of more than -0.05. The slope is calculated by the rise in elevation over the run in distance. For example, the last kilometer section has a gradient of -0.01 because the rise in elevation is 40 - 50 = -10 meters. The distance covered in 1000 meters. -10 / 1000 = 0.01. Your method should return true if there exists a dangerous…arrow_forwardThe file Parameters.java contains a program to test the variable-length method average.1. Read the code. Fill in the code to compute mean1 and mean2. Notice that you are calling the same method, but with a different number of parameters. 2. Add a call to find the average of a single integer, say 8. Print the result of the call. Is the result what you expected?3. Add a call with an empty parameter list and print the result. Is the result what you expected?4. Add a method called minimum to return the minimum value of the parameter list. Invoke this method in the main() and test it with different input numbers. //*******************************************************// Parameters.java//// Illustrates the concept of a variable parameter list.//*******************************************************import java.util.Scanner;public class Parameters{ //----------------------------------------------- // Calls the average and minimum methods with // different numbers of parameters.…arrow_forward: Design and implement a text-based Minesweeper game. Minesweeper is the classicsingle-player computer game where an NxN grid has B mines (or bombs) hidden across the grid. Theremaining cells are either blank or have a number behind them. The numbers reflect the number ofbombs in the surrounding eight cells. The user then uncovers a cell. If it is a bomb, the player loses.If it is a number, the number is exposed. If it is a blank cell, this cell and all adjacent blank cells (up toand including the surrounding numeric cells) are exposed. The player wins when all non-bomb cellsare exposed. The player can also flag certain places as potential bombs. This doesn't affect gameplay, other than to block the user from accidentally clicking a cell that is thought to have a bomb.(Tip for the reader: if you're not familiar with this game, please play a few rounds on line first.)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