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 11, Problem 11AW
Assume that the reference variable r refers to a serializable object. Write code that serializes the object to the file ObjectData.dat.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Shell script
A file has r=20000 STUDENT records of fixed-length. Each record has the following fields: NAME (30 bytes), SSN (10 bytes), ADDRESS (40 bytes), PHONE (9 bytes), BIRTHDATE (8 bytes), SEX (1 byte), MAJORDEPTCODE (4 bytes), MINORDEPTCODE (4 bytes), CLASSCODE (4 bytes, integer), and DEGREEPROGRAM (3 bytes). Suppose the block size is 512 bytes.
(a) Calculate the record size R in bytes.
(b) Calculate the blocking factor (number of tuples per block) and the number of blocks required.
(c) Calculate the average block accesses it takes to find a record by doing a linear search on the file.
(d) Assume the file is ordered by SSN; calculate the block accesses takes to search for a record given its SSN value by doing a binary search.
A file has r = 20, 000 STUDENT records of fixed length. Each record has the following fields: NAME (30 bytes), SSN (9 bytes), ADRESS(40 bytes), PHONE(9 bytes), BIRTHDATE (8 bytes), SEX(1 byte), CLASSCODE( 4 bytes, integer) MAJORDEPTCODE(4 bytes), MINORDEPTCODE(4 bytes), and DEGREEPROGRAM( 3 bytes). An additional byte is used as a deletion marker. Block size B = 512 bytes.
a) Calculate the blocking factor bfr (=floor(B/R), where R is the record size) and number of file blocks b, assuming unspanned organization (a record can’t be split across blocks).
b) Suppose only 80% of the STUDENT records have a value for PHONE, 85% for MAJORDEPTCODE, 15% for MINORDEPTCODE, and 90% for DEGREEPROGRAM. We use a variable-length record file. Each record has a 1-byte field type for each field in the record, plus the 1-byte deletion marker and a 1-byte end-of-record marker. Suppose that we use a spanned record organization, where each block has a 5-byte pointer to the next block (this space is not used…
Chapter 11 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Ch. 11.1 - Prob. 11.1CPCh. 11.1 - Prob. 11.2CPCh. 11.1 - Prob. 11.3CPCh. 11.1 - Prob. 11.4CPCh. 11.1 - Prob. 11.5CPCh. 11.1 - Prob. 11.6CPCh. 11.1 - Prob. 11.7CPCh. 11.1 - Prob. 11.8CPCh. 11.1 - Prob. 11.9CPCh. 11.1 - When does the code in a finally block execute?
Ch. 11.1 - What is the call stack? What is a stack trace?Ch. 11.1 - Prob. 11.12CPCh. 11.1 - Prob. 11.13CPCh. 11.1 - Prob. 11.14CPCh. 11.2 - What does the throw statement do?Ch. 11.2 - Prob. 11.16CPCh. 11.2 - Prob. 11.17CPCh. 11.2 - Prob. 11.18CPCh. 11.2 - Prob. 11.19CPCh. 11.3 - What is the difference between a text file and a...Ch. 11.3 - What classes do you use to write output to a...Ch. 11.3 - Prob. 11.22CPCh. 11.3 - What class do you use to work with random access...Ch. 11.3 - What are the two modes that a random access file...Ch. 11.3 - Prob. 11.25CPCh. 11 - Prob. 1MCCh. 11 - Prob. 2MCCh. 11 - Prob. 3MCCh. 11 - Prob. 4MCCh. 11 - FileNotFoundException inherits from __________. a....Ch. 11 - Prob. 6MCCh. 11 - Prob. 7MCCh. 11 - Prob. 8MCCh. 11 - Prob. 9MCCh. 11 - Prob. 10MCCh. 11 - Prob. 11MCCh. 11 - Prob. 12MCCh. 11 - Prob. 13MCCh. 11 - Prob. 14MCCh. 11 - Prob. 15MCCh. 11 - This is the process of converting an object to a...Ch. 11 - Prob. 17TFCh. 11 - Prob. 18TFCh. 11 - Prob. 19TFCh. 11 - True or False: You cannot have more than one catch...Ch. 11 - Prob. 21TFCh. 11 - Prob. 22TFCh. 11 - Prob. 23TFCh. 11 - Prob. 24TFCh. 11 - Find the error in each of the following code...Ch. 11 - // Assume inputFile references a Scanner object,...Ch. 11 - Prob. 3FTECh. 11 - Prob. 1AWCh. 11 - Prob. 2AWCh. 11 - Prob. 3AWCh. 11 - Prob. 4AWCh. 11 - Prob. 5AWCh. 11 - Prob. 6AWCh. 11 - The method getValueFromFile is public and returns...Ch. 11 - Prob. 8AWCh. 11 - Write a statement that creates an object that can...Ch. 11 - Write a statement that opens the file...Ch. 11 - Assume that the reference variable r refers to a...Ch. 11 - Prob. 1SACh. 11 - Prob. 2SACh. 11 - Prob. 3SACh. 11 - Prob. 4SACh. 11 - Prob. 5SACh. 11 - Prob. 6SACh. 11 - What types of objects can be thrown?Ch. 11 - Prob. 8SACh. 11 - Prob. 9SACh. 11 - Prob. 10SACh. 11 - What is the difference between a text file and a...Ch. 11 - What is the difference between a sequential access...Ch. 11 - What happens when you serialize an object? What...Ch. 11 - TestScores Class Write a class named TestScores....Ch. 11 - Prob. 2PCCh. 11 - Prob. 3PCCh. 11 - Prob. 4PCCh. 11 - Prob. 5PCCh. 11 - FileArray Class Design a class that has a static...Ch. 11 - File Encryption Filter File encryption is the...Ch. 11 - File Decryption Filter Write a program that...Ch. 11 - TestScores Modification for Serialization Modify...Ch. 11 - Prob. 10PC
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What are the four basic arithmetic operations?
Digital Fundamentals (11th Edition)
Add a method called checklndex to the MusicOrganizer class. It takes a single integer parameter and checks whet...
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Consider the following code (and assume that it is embedded in a complete and correct program and then run): ch...
Problem Solving with C++ (9th Edition)
What is the purpose of the let constructs in functional languages?
Concepts Of Programming Languages
Identify and correct the errors in each of the following code segments assume that all variables have been prop...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
What class do you use to work with random access files?
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
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
- True/False 10. The process of associating a file with an object in a program is called "reading" the file.arrow_forwardWrite the code segments based on the given descriptions: Declare a file pointer called input. Open a file called location.txt for reading using this pointer. If the file is not available, display “File does not exist.”. The content of the text file location.txt is as shown below. It includes the location, latitude and longitude values. FILE location.txt CONTENTS <Location> <Latitude> <Longitude> UTM 1.5523763 103.63322 KLCC 3.153889 101.71333 UM 3.1185 101.665 UMS 6.0367 116.1186 UNIMAS 1.465174 110.4270601 Ask the user to enter a location. Check if the user’s location can be found in the text file. If found, display the location, latitude and longitude as shown below. SAMPLE OUTPUT Enter a location: UM Location : UM Latitude : 3.1185 Longitude : 101.6650 Otherwise display “Sorry, location could not be found”. SAMPLE OUTPUT Enter a location : MMU Sorry, location could not be foundarrow_forwardA movie file has the following record structure:name ofthe movie producer director type productioncostAssume that the name of the movie is the primary key of the file. Thefield type refers to the type of the movie, for example, drama, sci-fi, horror, crimethriller, comedy and so forth. Input a sample set of records of your choice into themovie file.i) Implement a primary index-based ISAM file organization.ii) Implement secondary indexes on director, type and productioncost.arrow_forward
- Put the class definition in EV.h and the implementation of the constructors and functions in EV.cpp 1. Define a class called "EV", that represents the information of an electric vehicle. The EV is defined with these attributes: model (string), range(int), unit (string) and year (int). Functions of the EV class must perform the following operations: 1. A default constructor which sets all the numeric instance variables to zero. 2. A constructor with 4 parameters which sets the 4 instance variables to the corresponding values passed. 3. Implement a getter function for each of the 4 instance variables that will return the value of the instance variable. For example, the getX() function for the instance variable model must be called getModel(). 4. Implement a setter function for each instance variable that will assign to the instance variable to the value passed. For example, the setX() function for the instance variable model must be called setModel(). 5. An info function: this function…arrow_forwardcomplete the top cpp file; ***Use a factory function to create objects; throws an invalid_argument if one of the elements would make the object invalid.arrow_forwardMilestone #1 - Ask Quiz Type In a file called main.py, implement a program that asks the user for a quiz type and prints the file name for that quiz type. The program should have one input prompt: the integer value of the personality quiz number. Your program should print the welcome message and the list of the personality quizzes, ask for the test number, and then print the file name. You are required to use the provided dictionary with the personality quizzes names. The list of the personality quizzes should be printed in alphabetical order. See example below. Welcome to the Personality Quiz! What type of Personality Quiz do you want to run? 1 BabyAnimals 2 Brooklyn99 3 Disney 4 Hogwarts 5 MyersBriggs 6 Sesame Street 7 - StarWars 8 - Vegetablesarrow_forward
- WAP to read 4 student objects and write them into a file, then print total number of student number in file. After that read an integer and print details of student stored at this number in the file using random access and file manipulators.arrow_forwardHow to code this assignment JSON objects. Hint: Work on the methods in the order they are found in the documentation below. def read_last_line(file_path: str)->str: """ Reads the last line of the file at the specified file path. The function returns the last line of the file as a string, if the file is empty it will return an empty string (""). :param file_path: A path to a file :return: The last line of the file """ def read(file_path: str)->str: """ Reads the entire file at the specified file path. The function returns all the text in the file as a string, if the file is empty it will return an empty string (""). :param file_path: A path to a file :return: All the text in the file """ def write(file_path:str, text:str=''): """ Clears the file at the specified file path then writes the specified line to the file. If the function is invoked without a line parameter or the line variable is None nothing is written to…arrow_forwardGiven a valid file object, f, which of the following calls will return the entire contents of the file in a scalar x? x = f.readline() x = f.readlines() x = f.read() X = read(f)arrow_forward
- /** * The file path that is IOManager read and write an object from. This *file location will is used by @link #read()} and {@link #write(Object)}. * This method may not return a null value. If the path is not set this should return an empty string. * @param path The file location to be read and written to } # *1 public string getPath(); otFoundException, IllegalArgumentE; /* * Reads the object saved in the file located at the path returned by {@link #getPatF * @return An object saved in the file. 3* @throws IOException when something goes wrong in the IO process @throws ClassNotFoundException If the object located at the is a class that is not * by this version of your software @throws Illegal state Exception If the file path has not been set yet * */ public T read() throws IOException, ClassNotFoundException, IllegalStateException; /** * Writes and object to saved at the file located at the path returned by {@link #getPath( @param object The object saved in the file * @throws…arrow_forwardProgram is not run; error found in print(row) # Import the python CSV moduleimport csv# Create a python file object in read mode for the `baby_names.csv` file: csvfilecsvfile = open('baby_names.csv', 'r')# Loop over a DictReader on the filefor row in csv.DictReaderreader(csvfile): # Print each row print(row) # Add the rank and name to the dictionary: baby_names baby_names[row['RANK']] = row['NAME']# Print the dictionaryprint(baby_names.keys())arrow_forwardUnix assignment Purpose: The purpose of this assignment is to use various concepts of the C Shell. 0. Change your default login shell to the C Shell. 1. Create a .cshrc file in your home directory that will do the following: * Create the alias (lsall) that will do all of the following: display the date, and a recursive long list of all files in a directory. * Create the alias (whoson) that will display the date and a sorted list of users logged in. * Declare the LOCAL variable that controls the size of your history list to the value 200. * Declare the shell variable that will cause the C Shell to send a message to your terminal whenever one of your background commands complete. 2. Create a .login file in your home directory to do the following. * Declare the GLOBAL Terminal Type variable to the value vt100. Display the value of the variable. Logout and log back in to make sure your .cshrc and .login files are automatically executed. Create a lab8.scr…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License