0% found this document useful (0 votes)
2 views

Cp Midterm

Debugging involves identifying and fixing errors in programs, utilizing techniques such as backtracking, debugging tools, and log analysis. Exception handling is a method for managing errors during program execution, with try, catch, and finally blocks to handle exceptions. Additionally, the document discusses file types, paths, and operations in programming, including the use of Path and Files classes in Java.

Uploaded by

ngg8jd4mdz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Cp Midterm

Debugging involves identifying and fixing errors in programs, utilizing techniques such as backtracking, debugging tools, and log analysis. Exception handling is a method for managing errors during program execution, with try, catch, and finally blocks to handle exceptions. Additionally, the document discusses file types, paths, and operations in programming, including the use of Path and Files classes in Java.

Uploaded by

ngg8jd4mdz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Debugging is the process of identifying and rectifying errors in a program that leads to unexpected behavior.

Debugging Process

- Examining the error symptoms


- Identifying the cause
- Fixing the error

Techniques

- Understanding the Problem


- Backtracking: also called backward debugging
- Debugging Tools: Chrome DevTools, Testsigma, and dbForger
- Breakpoints and Stepping: breakpoint is the point in the code to temporarily stop the execution of the program
to inspect the state of its functionality. stepping technique to manually move through each line of code to study
variables and data structures for problems.
- Binary Search: divided into halves
- Rubber Ducking: someone else to identify the issue;rubber duck
- Log Analysis
- Clustering Bugs
- Take Breaks & Notes

exception is an unexpected or error condition encountered in programming.

Exception handling refers to the object-oriented techniques that manage or resolve such errors.

runtime error happens if an unplanned exception occurs during a program’s execution

syntax error if discovered during program compilation

Error Class – represents more serious errors that a program usually might not recover from.

Exception Class – represents less serious errors that indicate unusual conditions that arise while a program is running
and from which the program can recover.

try block This is placed when a programmer creates a segment of code in which something might go wrong.

catch block To handle a thrown exception, one or more catch blocks can be added following a try block.
finally block is used when actions must be performed at the end of a try… catch sequence.

computer file is a collection of data stored on a nonvolatile device or a permanent storage device such as a hard disk,
universal serial bus (USB) drive, compact disk, and reel or cassette of magnetic tape.

Text files contain data that can be read in a text editor as the data is encoded using a scheme (ASCII or Unicode).

data files that contain facts and figures, including a payroll file with employee numbers, names, and salaries.

OR program files or application files that store software instructions

Binary files contain data items that have not been encoded as text. (0s and 1s)

root directory or main directory of the storage device can be used to store a permanent file.

Path is a complete list of the disk drive and the hierarchy of directories in which a file resides in.

backslash (\) in the Windows operating system is the path identifier which separates the path components.

slash (/) is used as the delimiter in the Solaris (UNIX) operating system.

Path class creates objects containing information about files and directories, including their locations, sizes, creation
dates, and whether they exist.
Files class performs operations on files and directories, including deletion, determining their attributes, and creating
input and output streams.

nio in java.nio stands for new input/output as its classes are “new”

Creating a Path can be initiated by determining the file system on the host computer by using a statement

factory is an object that creates other objects.

Paths class is considered a helper class that eliminates the need to create a FileSystem object.

Path object: Path filePath = Paths.get("C:\\Java\\Chapter.11\\SampleFile.txt");

absolute path is a complete path that does not need any information to locate a file on a system.

relative path depends on other path information. For example, a simple path such as SampleFile.txt is relative

To convert a relative path to an absolute path, the toAbsolutePath() method is used.

String toString() - Returns the String representation of the path, eliminating double backslashes

Path getFileName() - Returns the file or directory denoted by this Path; the last item in the sequence of name elements.

int getNameCount() - Returns the number of name elements in the Path

Path getName(int) - Returns the name in the position of the Path specified by the integer parameter

Index is used to access a Path’s elements

top-level element in the directory structure is located at index 0,

lowest element in the structure is accessed by the getName() method.

checkAccess() method is used to verify that a file exists and that the program can access it as needed.
No argument – checks that the file exists.

READ – checks that the file exists and the program has permission to read the file

WRITE – checks that the file exists and the program has permission to write to the file

EXECUTE – checks that the file exists and the program has permission to execute the file

readAttributes() method of the Files class can retrieve useful information about a file.

ScreenOut class shows an application declaring a String of letter grades allowed in a course.

getBytes() method converts the String to an array of bytes.

You might also like