Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in Java please define the following parent class and its child class please comment thought process 2 PRINTWRITER CLASS Java provides output facilities through various

in Java please define the following parent class and its child class

please comment thought process

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

2 PRINTWRITER CLASS Java provides output facilities through various classes. You are likely very familiar with System.out by now (using its output methods print/println/printf). Inspecting the system class you will see that out, a static field, is an instance of the PrintStream class. This endows it with many methods such as print/println/printf. To write to a file, we will use the java.io.PrintHriter class. It is quite similar to System.out in that Printwriters have print/printin/printf methods. When constructing a Printwriter, the constructor determines the destination of output. Should a File be passed in, all output is directed the file. PrintWriter pwl -new PrintWriter (System.out); Printwriter pw2 new Printwriter("myfile.txt") Note: PrintWriters do not always push their output to the destination immediately. When printing to a file, call close() to ensure all output is pushed to the file When printing to the screen, one may need to call flush ) to get text to appear (especially when you've written part of a line but not the newline character). In subclasses, flush ) can be added to print/println to do this. Make sure NOT to call close () on a PrintWriter that is writing to the screen: this will close System.out and prevent ALL further output from being printed to the screen. 2 PRINTWRITER CLASS Java provides output facilities through various classes. You are likely very familiar with System.out by now (using its output methods print/println/printf). Inspecting the system class you will see that out, a static field, is an instance of the PrintStream class. This endows it with many methods such as print/println/printf. To write to a file, we will use the java.io.PrintHriter class. It is quite similar to System.out in that Printwriters have print/printin/printf methods. When constructing a Printwriter, the constructor determines the destination of output. Should a File be passed in, all output is directed the file. PrintWriter pwl -new PrintWriter (System.out); Printwriter pw2 new Printwriter("myfile.txt") Note: PrintWriters do not always push their output to the destination immediately. When printing to a file, call close() to ensure all output is pushed to the file When printing to the screen, one may need to call flush ) to get text to appear (especially when you've written part of a line but not the newline character). In subclasses, flush ) can be added to print/println to do this. Make sure NOT to call close () on a PrintWriter that is writing to the screen: this will close System.out and prevent ALL further output from being printed to the screen

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

More Books

Students also viewed these Databases questions