All Tech at one spot
Storage devices of a computer system can be broadly classified into two categories: volatile storage and non-volatile Storage.
Volatile storage is temporary; values stored invariables are lost when a computer is shutdown.A Java program that stores a value ina variable uses RandomAccess Memory (RAM). Apart from variables, objects and their references are generally stored in RAM,once the programterminates or the computer shuts down, the data is lost.
Non-volatile storage is permanent storage; data is not lost when a computer loses power. When a
Java program is saved on a disk, we are using permanent storage.
Text files contain data that can be read ina text editor because the data has been encoded using a scheme such asASCII or Unicode.
Text files canbe data files that contain facts, such as a payroll file that contains employee numbers, names, and salaries; or some text files can be program files or application files that store software instructions.
Binary files contain data that has not been encoded as text. Their contents are inbinary format,
which means the data is accessed interms of bytes.
Thejava.io.File class encapsulates informationabout the properties ofa file or adirectory. Fileclass
can be used to access attributes of files and directories.
There are nearly 30 methods of File Class that can be used to perform various operations on a
file or a directory.
The File class provides following constructors to refer a file or a directory.
File(Stringpath)
File(Stringdirectory_path, String file_name)
File(Filedirectory, String filejname)
A stream is an abstract representation of an input or output device that is used as a source or destination for data. We can visualize a stream as a sequence ofbytes that flows into the program or that flows out of our program.
Acharacter is generally stored usingASCII or Unicode format but when it is used for calculation
purpose; its binary value is meaningful.
Java streams can be classified into two basic types, namely input stream and output stream. An
input stream reads data from the source (file, keyboard) while the output stream writes data to
the destination (file,output device).
Character Stream Classes
Character stream classes are a group of classes available injava.io package. They can be used
to read and write 16-bit Unicode characters
1. Which of the following statements is true?
a) Volatile storage lasts only a few seconds
b) Volatile storage is lost when a computer is shutdowns
c) Computer disks are volatile storage devices
d) All of the above are true
2. Which of the following refers to a collection of data stored on a nonvolatile device in a computer system?
a) File
b) Application
c) Volatile data
d) hard-disk
3. The data hierarchy occurs in which of the following order from the smallest to largest piece of data?
a) character : field : record : file
b) file:character:field:record
c) file:character:record:field
d) character:field:file:record
4. Which of the following is true about streams?
a) Streams always flow in two directions.
b) Streams are channels through which the data flow.
c) Only one stream can be open in a program at a time.
d) All of the above are true.
5. Which of the following is used as a separator between fields of a record?
a) path
b) Delimiter
c) Variable
d) Space
6. Scanner class can be used for performing which of the following operations?
a) Accept input from the keyboard
b) Read from the file
c) parse a string separated by delimiters
d) All of the above