Archive for October, 2009

What is fileInputStream class?

The FileInputStream class is used to is used to read binary data from a file. It is used to perform simple file input operations. It reads data in a sequential manner, but can skip a region of data as per requirement. It generally reads data in a sequential manner, but can skip a region of data as per requirement. FileInputStream class can be instantiated by using any of the following three constructors:

  • FileInputStream (String name)
  • FileInputStream (File file)
  • FileInputStream (FileDescriptor fdObject)
    • Share/Bookmark

    What is data-type conversion?

    Data type conversion is a technique of converting the data type of a variable to another data type. Two kinds of data type conversions are available in Java.

    1. Automatic: Automatic conversion takes place when the following two conditions are fulfilled:

      1. The two types are compatible.
      2. The destination type is larger than the source type.
    • Share/Bookmark

    The Console class is used to provide methods to read from and write to the console objects. It extends the Object class. It provides the readPassword() method to read a password from the console. If the underlying virtual machine has a console, it can be obtained by invoking the System.console() method. If no console device is available, then an invocation of the System.console() method returns null.

    The Console class provides the following methods:

    • Share/Bookmark

    How to declare a package?

    The package statement is used to declare packages. The word package is a keyword in Java. This statement is not technically needed to write a complete Java program. However, if it appears, it must be the first executable statement in the program. Only comments or white spaces are allowed before a package statement. There can be only one package declaration in a program. If no package declaration appears, the class will belong to the default package.

    For example, the following source code file defines a class named ClassA in the package named package4:

    package package4;

    • Share/Bookmark