Sabtu, 31 Mei 2014

Rian Saadillah

DOS System Files


The modern DOS operating system is distributed on 3-5 high density floppy disks. It comes with backup utilities and (depending on how the lawyers feel) disk compression drivers. However, all the stuff that goes into C:\DOS and its subdirectories are programs and utilities. The core DOS operating system consists of six files:

The boot sector is a 512 byte record placed at the beginning of the C: drive when DOS was installed, or placed there subsequently using the "sys c:" command.

Two "hidden" files are stored in the root directory of the C: drive. They do not show up in a DIR listing unless the /A switch is used. On IBM PC DOS systems, they are IBMBIO.SYS and IBMDOS .SYS. On MS DOS systems, they are called IO.SYS and MSDOS.SYS. These files form the kernel of the DOS system.

COMMAND.COM is the "shell" or command interpreter. It prints out the "C:\&gt " prompt and reads user commands. It also supports BAT files.

The user configuration files are CONFIG.SYS and AUTOEXEC.BAT. The reader is assumed to be familiar with these files.

COMMAND.COM is initially stored in the C:\ root directory. The problem is that OS/2 and Windows NT have their own versions of COMMAND.COM. To avoid confusion, each COMMAND.COM should be stored in the subdirectory that belongs to its particular operating system. In normal use, this means that the DOS version should be in C:\DOS. To relocate it, two statements must be added to the user configuration files:

"SHELL=C:\DOS\COMMAND.COM" is added to CONFIG.SYS.

"SET COMSPEC=C:\DOS\COMMAND.COM" is added to AUTOEXEC.BAT.

The hidden files IBMBIO, IBMDOS, IO, or MSDOS have names that do not conflict with each other or with any system file belonging to any other operating system. They can stay in the C:\ root directory no matter what gets added to the system. This means that the volatile part of the DOS system consists of the boot record, C:\CONFIG.SYS, and C:\AUTOEXEC.BAT.
Putting DOS on a Floppy

To install a copy of the DOS system files on a floppy, simply issue the command:

FORMAT A: /S

Recovering Damaged DOS System Files

If the DOS system files have been clobbered, boot the same release of DOS from a floppy. When using the Install Diskettes for DOS, wait till the first panel appears and then escape from the installation system to the command prompt. Type

SYS C: 

Read More

Jumat, 30 Mei 2014

Rian Saadillah

Sistem berkas FAT


Sistem berkas FAT atau FAT File System adalah sebuah sistem berkas yang menggunakan struktur tabel alokasi berkas sebagai cara dirinya beroperasi. Untuk penyingkatan, umumnya orang menyebut sistem berkas FAT sebagai FAT saja. Kata FAT sendiri adalah singkatan dari File Allocation Table, yang jika diterjemahkan secara bebas ke dalam Bahasa Indonesia menjadi Tabel Alokasi Berkas. Arsitektur FAT sekarang banyak digunakan secara luas dalam sistem komputer dan kartu-kartu memori yang digunakan dalam kamera digital atau pemutar media portabel.

FAT pertama kali dikembangkan oleh Bill Gates dan Marc McDonald, pada tahun 1976-1977. Sistem berkas ini merupakan sistem berkas utama untuk sistem operasi yang ada saat itu, termasuk di antaranya adalah Digital Research Disk Operating System (DR-DOS), OpenDOS, FreeDOS, MS-DOS, IBM OS/2 (versi 1.1, sebelum berpindah ke sistem HPFS), dan Microsoft Windows (hingga Windows Me). Untuk disket, FAT telah distandardisasikan sebagai ECMA-107 dan ISO/IEC 9293. Standar-standar tersebut hanya mencakup FAT12 dan FAT16 tanpa dukungan nama berkas panjang, karena memang beberapa bagian dalam standar nama file panjang di dalam sistem berkas FAT telah dipatenkan.

Sistem berkas ini digunakan oleh sistem operasi MS-DOS (hanya versi FAT12 dan FAT16), Windows (hampir semua versi Windows; untuk versi FAT yang didukung olehnya lihat pada bagian versi), GNU/Linux, dan masih banyak sistem operasi lainnya yang juga mendukung, termasuk Macintosh Mac OS/X.

Versi 
Ada beberapa versi dari sistem berkas FAT, yang dibedakan dari berapa banyak unit alokasi yang didukungya, yakni sebagai berikut:

FAT12
FAT16
FAT32

exFAT

Tabel Alokasi Berkas
Tabel alokasi berkas atau File Allocation Table merupakan sebuah tabel yang dipelihara di dalam hard disk atau media penyimpanan lainnya oleh sistem operasi yang bertindak sebagai "daftar isi media penyimpanan", yang menunjukan di mana direktori dan berkas disimpan di dalam disk.

Ketika sebuah media penyimpanan diformat dengan menggunakan FAT, sistem berkas ini akan membuat sebuah tabel alokasi berkas yang disimpan pada lokasi yang dekat dengan permulaan media penyimpanan tersebut. Media penyimpanan yang dimaksud adalah media penyimpanan seperti sebuah hard disk, sebuah partisi dalam sebuah hard disk, atau media penyimpanan portabel. Selain membuat satu tabel alokasi berkas, sistem berkas tersebut juga membuat salinan dari sistem berkas tersebut, dan berada pada media penyimpanan yang sama. Jika salah satu salinan mengalami kerusakan, maka sistem berkas akan menggunakan salinan yang lain, dan mengganti tabel yang rusak tersebut dengan salinan yang masih baik (cara kerja ini disebut dengan FAT Mirroring, yang bekerja seperti layaknya RAID 1). Lokasi tabel alokasi berkas ditentukan di dalam sebuah area yang disebut dengan BIOS Parameter Block (BPB) dalam boot sector sebuah media penyimpanan yang menggunakan sistem berkas FAT.

FAT16 akan membuat dua buah tabel alokasi berkas, yang diberi nama FAT1 dan FAT2. Tabel alokasi berkas akan diletakkan pada area tertentu, yakni pada lokasi yang berdekatan dengan boot sector. Tabel alokasi berkas akan berisi informasi-informasi berikut:

Unused, yang menandakan bahwa unit alokasi tersebut tidak terpakai
In use, yang menandakan bahwa unit alokasi tersebut tidak dapat digunakan karena sedang digunakan oleh sebuah berkas tertentu.
Bad, yang menandakan bahwa unit alokasi tersebut tidak dapat digunakan karena mengalami kerusakan.
Last cluster, yang menandakan bahwa unit alokasi tersebut merupakan unit alokasi terakhir yang dimiliki oleh sebuah berkas.
Dalam strukturnya, FAT16 membedakan antara direktori akar (root directory) dan direktori lainnya, karena memang desain FAT16 menentukan lokasi direktori akar pada lokasi yang spesifik, dan memiliki batasan jumlah entri yang dapat disimpan (hanya dapat menampung 512 entri).

Direktori akar pada sistem berkas FAT16 terdiri dari sebuah ukuran yang tetap dan diketahui, karena berkas-berkas sistem operasi biasanya langsung diletakkan segera setelah direktori akar tersebut. Lokasi yang diketahui untuk berkas-berkas sistem operasi ini mengizinkan sistem operasi DOS, OS/2, atau Windows NT untuk langsung memulai proses booting sistem operasi. Tetapi, keputusan desain ini juga membatasi jumlah file yang dapat ditampung di dalam sebuah direktori akar dari sebuah volume FAT16.

Entri-entri di dalam direktori akar dan juga sub-direktori tidak diurutkan sehingga proses pencarian terhadap berkas-berkas tertentu dapat memakan waktu yang lama, apalagi jika volume tersebut mengandung banyak berkas dalam sebuah direktori.


Tabel alokasi berkas dan juga direktori akar selalu diletakkan pada awal sebuah volume, atau biasanya terletak pada lokasi track terluar dari sebuah disk. Entri-entri tersebut merupakan entri-entri yang sering sekali dibaca dari sebuah disk, utamanya pada sistem operasi yang mendukung multitasking, yang membutuhkan banyak pergerakan head hard disk yang lamban.(Wikipedia)
Read More
Rian Saadillah

Type Data pada Java


Tipe data adalah salah satu konsep dasar pemrograman. Sebagai seorang programer, seharusnya menguasai hal ini dengan baik. Untuk mempelajari tipe data, sebaiknya menggunakan bahasa pemrograman yang strongly typed, misalnya Java.

Tidak seperti pada bahasa PHP, Java adalah bahasa pemrograman yang strongly typed. Kita tidak bisa tidak acuh terhadap tipe data. Kita harus mengetahui data seperti apa yang disimpan ke dalam variabel. Misalnya untuk menyimpan umur kita gunakan variabel yang bertipe Integral, karena umur hanya berupa angka bulat tanpa pecahan.

Selain itu, Java juga bersifat statically typed. Maksudnya adalah setiap variabel harus dideklarasikan sebelum digunakan. Java akan mengecek tipe data pada compile-time.

int i = 0;

Tipe data primitif adalah tipe data standar yang tidak diturunkan dari objek manapun. Java memiliki 8 tipe data primitif, yaitu: byte, short, int, long, float, double, boolean, char. Berikut ini adalah pembahasan untuk masing-masing tipe data.

1. boolean. Tipe data boolean adalah tipe data Logical, yang hanya memiliki 2 nilai literal, yaitu true dan false.

boolean nilai = true;

2. char. Tipe data char adalah tipe data Textual, yang merepresentasikan karakter unicode 16-bit. Nilai literalnya harus diapit dengan tanda petik tunggal (‘).

char huruf = 'a';

3. byte. Tipe data byte adalah tipe data Integral 8-bit. Memiliki rentang nilai antara -27 sampai 27 – 1 atau dari -128 sampai 127.

byte angka = 100;

4. short. Tipe data short adalah tipe data Integral 16-bit. Memiliki rentang nilai antara -215 sampai 215 – 1 atau dari -32768 sampai 32768.

short angka = 1000;

5. int. Tipe data int adalah tipe data Integral 32-bit. Memiliki rentang nilai antara -231 sampai 231 – 1 atau dari -2,147,483,648 sampai 2,147,483,647.

int angka = 1000000;

6. long. Tipe data long adalah tipe data Integral 64-bit. Memiliki rentang nilai antara -263 sampai 263 – 1 atau dari -9,223,372,036,854,775,808 sampai 9,223,372,036,854,775,807.
Tipe data Integral (byte, short, int, long) memiliki default nilai literal int, kecuali diberi akhiran L yang berarti bertipe long. Tipe data Integral dapat menggunakan sistem bilangan desimal, oktal, atau heksadesimal.

int desimal = 26; // angka 26 dalam desimal
int oktal = 032; // angka 26 dalam oktal (diberi awalan 0)
int heksa = 0x1a; // angka 26 dalam heksadesimal (diberi awalan 0x)
long angkaBesar = 1000000000000L; // angka desimal bertipe long

7. float. Tipe data float adalah tipe data Floating Point 32-bit. Nilai literalnya mengandung pecahan (dipisahkan dengan tanda titik ‘.’)

float pi = 3.14F;

8. double. Tipe data double adalah tipe data Floating Point 64-bit. Nilai literal default untuk float dan double adalah double, kecuali diberi akhiran F seperti pada contoh nomor 7 di atas.

float pecahan = 7.65F;
double pecahanDouble = 1.2345;

Jika variabel float yang diinisialisasi dengan suatu nilai tanpa akhiran F, akan muncul pesan kesalahan: “possible loss of precision“.
Nilai literal untuk Floating Point juga bisa menggunakan notasi E (10 pangkat n).

// ketiga variabel di bawah ini memiliki nilai yang sama 123.4
float f1 = 123.4F;
double d1 = 123.4;
double d2 = 1.234E2;

Sebenarnya tipe data primitif sudah memiliki nilai default pada saat dideklarasikan (meskipun tanpa inisialisasi), kecuali untuk variabel lokal. Nilai default untuk masing-masing tipe data adalah sebagai berikut:

Tipe Data   Nilai Default
--------------------------------------------------
boolean     false
char        '\u0000' (merepresentasikan ASCII null)
byte        0
short       0
int         0
long        0L
float       0.0F
double      0.0

Pada variabel lokal, deklarasi tipe data harus disertai dengan inisialisasi. Jika tidak, pastikan untuk memberikan nilai kepada variabel tersebut sebelum digunakan. Mengakses lokal variabel tanpa inisialisasi akan menghasilkan pesan kesalahan pada saat meng-compile (compile-time error).
Read More
Rian Saadillah

Lesson: Working with Geometry

In prior lessons, you have learned the graphics concept, including basic information about the coordinate system and graphic object creation. Now, you will progress to more detailed lessons about the 2D graphics classes. This lesson shows you how to use the Graphics2D class to draw graphic primitives as well as arbitrary shapes, and how to display graphics with fancy outline and fill styles. These topics are discussed in the following sections.

Drawing Geometric Primitives

This section explains how to create standard shapes such as points, lines, curves, arcs, rectangles, and ellipses.

Drawing Arbitrary Shapes

This section explains how to draw shapes represented by combinations of straight geometric primitives by using the GeneralPath class.

Filling and Stroking

This section explains how to set the stroke and paint attributes to control the outline and fill styles applied to Shape objects and text.
Read More
Rian Saadillah

Polymorphism

The dictionary definition of polymorphism refers to a principle in biology in which an organism or species can have many different forms or stages. This principle can also be applied to object-oriented programming and languages like the Java language. Subclasses of a class can define their own unique behaviors and yet share some of the same functionality of the parent class.

Polymorphism can be demonstrated with a minor modification to the Bicycle class. For example, a printDescription method could be added to the class that displays all the data currently stored in an instance.

public void printDescription(){
    System.out.println("\nBike is " + "in gear " + this.gear
        + " with a cadence of " + this.cadence +
        " and travelling at a speed of " + this.speed + ". ");
}

To demonstrate polymorphic features in the Java language, extend the Bicycle class with a MountainBike and a RoadBike class. For MountainBike, add a field for suspension, which is a String value that indicates if the bike has a front shock absorber, Front. Or, the bike has a front and back shock absorber, Dual.

Here is the updated class:

public class MountainBike extends Bicycle {
    private String suspension;

    public MountainBike(
               int startCadence,
               int startSpeed,
               int startGear,
               String suspensionType){
        super(startCadence,
              startSpeed,
              startGear);
        this.setSuspension(suspensionType);
    }

    public String getSuspension(){
      return this.suspension;
    }

    public void setSuspension(String suspensionType) {
        this.suspension = suspensionType;
    }

    public void printDescription() {
        super.printDescription();
        System.out.println("The " + "MountainBike has a" +
            getSuspension() + " suspension.");
    }
}

Note the overridden printDescription method. In addition to the information provided before, additional data about the suspension is included to the output.

Next, create the RoadBike class. Because road or racing bikes have skinny tires, add an attribute to track the tire width. Here is the RoadBike class:

public class RoadBike extends Bicycle{
    // In millimeters (mm)
    private int tireWidth;

    public RoadBike(int startCadence,
                    int startSpeed,
                    int startGear,
                    int newTireWidth){
        super(startCadence,
              startSpeed,
              startGear);
        this.setTireWidth(newTireWidth);
    }

    public int getTireWidth(){
      return this.tireWidth;
    }

    public void setTireWidth(int newTireWidth){
        this.tireWidth = newTireWidth;
    }

    public void printDescription(){
        super.printDescription();
        System.out.println("The RoadBike" + " has " + getTireWidth() +
            " MM tires.");
    }
}

Note that once again, the printDescription method has been overridden. This time, information about the tire width is displayed.

To summarize, there are three classes: Bicycle, MountainBike, and RoadBike. The two subclasses override the printDescription method and print unique information.

Here is a test program that creates three Bicycle variables. Each variable is assigned to one of the three bicycle classes. Each variable is then printed.

public class TestBikes {
  public static void main(String[] args){
    Bicycle bike01, bike02, bike03;

    bike01 = new Bicycle(20, 10, 1);
    bike02 = new MountainBike(20, 10, 5, "Dual");
    bike03 = new RoadBike(40, 20, 8, 23);

    bike01.printDescription();
    bike02.printDescription();
    bike03.printDescription();
  }
}

Read More
Rian Saadillah

Introduction to Java Classes

Illustration
A class is nothing but a blueprint or a template for creating different objects which defines its properties and behaviors. Java class objects exhibit the properties and behaviors defined by its class. A class can contain fields and methods to describe the behavior of an object.

Methods are nothing but members of a class that provide a service for an object or perform some business logic. Java fields and member functions names are case sensitive. Current states of a class’s corresponding object are stored in the object’s instance variables. Methods define the operations that can be performed in java programming.

A class has the following general syntax:

<class modifiers>class<class name>
<extends clause> <implements clause>{

// Dealing with Classes (Class body)
<field declarations (Static and Non-Static)>
<method declarations (Static and Non-Static)>
<Inner class declarations>
<nested interface declarations>
<constructor declarations>
<Static initializer blocks>
}

Below is an example showing the Objects and Classes of the Cube class that defines 3 fields namely length, breadth and height. Also the class contains a member function getVolume().

public class Cube {

int length;
int breadth;
int height;
public int getVolume() {
return (length * breadth * height);
}
}

How do you reference a data member/function?
This is accomplished by stating the name of the object reference, followed by a period (dot), followed by the name of the member inside the object.
( objectReference.member ). You call a method for an object by naming the object followed by a period (dot), followed by the name of the method and its argument list, like this: objectName.methodName(arg1, arg2, arg3).

For example:
cubeObject.length = 4;
cubeObject.breadth = 4;
cubeObject.height = 4;
cubeObject.getvolume()

Class Variables – Static Fields

We use class variables also know as Static fields when we want to share characteristics across all objects within a class. When you declare a field to be static, only a single instance of the associated variable is created common to all the objects of that class. Hence when one object changes the value of a class variable, it affects all objects of the class. We can access a class variable by using the name of the class, and not necessarily using a reference to an individual object within the class. Static variables can be accessed even though no objects of that class exist. It is declared using static keyword.

Class Methods – Static Methods

Class methods, similar to Class variables can be invoked without having an instance of the class. Class methods are often used to provide global functions for Java programs. For example, methods in the java.lang.Math package are class methods. You cannot call non-static methods from inside a static method.

Instance Variables

Instance variables stores the state of the object. Each class would have its own copy of the variable. Every object has a state that is determined by the values stored in the object. An object is said to have changed its state when one or more data values stored in the object have been modified. When an object responds to a message, it will usually perform an action, change its state etc. An object that has the ability to store values is often said to have persistence.

Consider this simple Java program showing the use of static fields and static methods

// Class and Object initialization showing the Object Oriented concepts in Java
class Cube {

int length = 10;
int breadth = 10;
int height = 10;
public static int numOfCubes = 0; // static variable
public static int getNoOfCubes() { //static method
return numOfCubes;
}
public Cube() {
numOfCubes++; //
}
}

public class CubeStaticTest {

public static void main(String args[]) {
System.out.println("Number of Cube objects = " + Cube.numOfCubes);
System.out.println("Number of Cube objects = "
+ Cube.getNoOfCubes());
}
}

Final Variable, Methods and Classes

In Java we can mark fields, methods and classes as final. Once marked as final, these items cannot be changed.


Variables defined in an interface are implicitly final. You can’t change value of a final variable (is a constant). A final class can’t be extended i.e., final class may not be subclassed. This is done for security reasons with basic classes like String and Integer. It also allows the compiler to make some optimizations, and makes thread safety a little easier to achieve. A final method can’t be overridden when its class is inherited. Any attempt to override or hide a final method will result in a compiler error.

Introduction to Java Objects

The Object Class is the super class for all classes in Java.

Some of the object class methods are

equals
toString()
wait()
notify()
notifyAll()
hashcode()
clone()

An object is an instance of a class created using a new operator. The new operator returns a reference to a new instance of a class. This reference can be assigned to a reference variable of the class. The process of creating objects from a class is called instantiation. An object encapsulates state and behavior.

An object reference provides a handle to an object that is created and stored in memory. In Java, objects can only be manipulated via references, which can be stored in variables.

Creating variables of your class type is similar to creating variables of primitive data types, such as integer or float. Each time you create an object, a new set of instance variables comes into existence which defines the characteristics of that object. If you want to create an object of the class and have the reference variable associated with this object, you must also allocate memory for the object by using the new operator. This process is called instantiating an object or creating an object instance.

When you create a new object, you use the new operator to instantiate the object. The new operator returns the location of the object which you assign o a reference type.

Below is an example showing the creation of Cube objects by using the new operator.

public class Cube {

int length = 10;
int breadth = 10;
int height = 10;
public int getVolume() {
return (length * breadth * height);
}
public static void main(String[] args) {
Cube cubeObj; // Creates a Cube Reference
cubeObj = new Cube(); // Creates an Object of Cube
System.out.println("Volume of Cube is : " + cubeObj.getVolume());
}

}

Method Overloading

Method overloading results when two or more methods in the same class have the same name but different parameters. Methods with the same name must differ in their types or number of parameters. This allows the compiler to match parameters and choose the correct method when a number of choices exist. Changing just the return type is not enough to overload a method, and will be a compile-time error. They must have a different signature. When no method matching the input parameters is found, the compiler attempts to convert the input parameters to types of greater precision. A match may then be found without error. At compile time, the right implementation is chosen based on the signature of the method call

Below is an example of a class demonstrating Method Overloading


public class MethodOverloadDemo {

void sumOfParams() { // First Version
System.out.println("No parameters");
}
void sumOfParams(int a) { // Second Version
System.out.println("One parameter: " + a);
}
int sumOfParams(int a, int b) { // Third Version
System.out.println("Two parameters: " + a + " , " + b);
return a + b;
}
double sumOfParams(double a, double b) { // Fourth Version
System.out.println("Two double parameters: " + a + " , " + b);
return a + b;
}
public static void main(String args[]) {
MethodOverloadDemo moDemo = new MethodOverloadDemo();
int intResult;
double doubleResult;
moDemo.sumOfParams();
System.out.println();
moDemo.sumOfParams(2);
System.out.println();
intResult = moDemo.sumOfParams(10, 20);
System.out.println("Sum is  " + intResult);
System.out.println();
doubleResult = moDemo.sumOfParams(1.1, 2.2);
System.out.println("Sum is  " + doubleResult);
System.out.println();
}

}

Referensi : http://www.javabeginner.com
Read More