Posted by : Octo The Azura Selasa, 05 Mei 2015


FIFTH MEETING : ABSTRACT CLASS
NAME
RAHMATUL MAHDALINA
STUDENT NUMBER
L200134004
CLASS
X
 
A.    Objective
Students are understand about abstract class in java

B.     Basic Teory
       Java supplied a mechanism that is enable a method in class must not by definition. This method called abstract method and the class called abstract class.
       Definition of class a given by derivative class. In every derivative class from abstract class must definite methods that are rated abstract method.
       Abstract class created firstly knowing that subclasses are operation appropriate with the method but, between subclass with other subclass have differences action.

C.    Tools and Materials
·      Laptop
·      Practice Object Oriented Programming Modul
·      Software NetBeans IDE 8.0.2
·      Java Development Kit (JDK) 1.8.0_31

D.    Work Step
EXPERIMENT
Steps of experiment:
1.    Create new class by name “Kendaraan.java” like in the picture
            package Abstract_cls;

/**
 *
 * @author Octopus_girl
 */
public abstract class Kendaraan {
    protected String nama;
    public abstract void jalankan();
}

2.    Save like the class name and compile
3.    Create new class by name “Sepeda.java”, write the program code like this :
            package Abstract_cls;

/**
 *
 * @author Octopus_girl
 */
public class Sepeda extends Kendaraan {
    public Sepeda (String nama){
        this.nama = nama;
    }
    public void jalankan(){
        System.out.println("Duduklah diatas Sadel "+""+this.nama+" dan kayuhlah");
    }
   
4.    Save file like the name of class and compile
5.    Then, create new class with main method () that is implementation of Sepeda class. Write the program code like this :
package Abstract_cls;

/**
 *
 * @author Octopus_girl
 */
public class TesAbstractSepeda {
    public static void main (String[]args){
        Sepeda sepedaku = new Sepeda ("Sepeda Ontel");
        sepedaku.jalankan();
    }
}
6.    Save like class name and compile
7.    Observing and record the result


EXERCISE

1.    Create new class with name “Mobil.java” that is subclass from kendaraan and create class “TesAbstrakMobil.java” as implementation of class “Mobil.java”
package Abstract_cls;

/**
 *
 * @author Octopus_girl
 */
public class Mobil extends Kendaraan {
        public Mobil (String nama){
        this.nama = nama;
    }
    public void jalankan(){
        System.out.println("Duduklah didepan Setir "+""+this.nama+" dan Hidupkan mesin");
    }
    public void bunyikanTlakson(){
        System.out.println("Bunyikan Tlakson "+""+this.nama+" Saat di persimpangan");
    }

}

package Abstract_cls;

/**
 *
 * @author Octopus_girl
 */
public class TesAbstractMobil {
    public static void main (String[]args){
        Mobil mobiltua = new Mobil ("Mobil Tua");
        mobiltua.jalankan();
        mobiltua.bunyikanTlakson();
    }
}
2.    Follow the steps
3.    Add one new method in class “Mobil.java”
    public void bunyikanTlakson(){
     }
4.    Result from the program


E.   Analysis
     Abstract method in the Kendaraan class can be access in the other class and other class must not definite the method cause can be generated from class Kendaraan.

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Welcome to My Blog

Popular Post

Blogger templates

Pengikut

Diberdayakan oleh Blogger.

Arsip Blog

- Copyright © Mahdalina -Robotic Notes- Powered by Blogger - Designed by Johanes Djogan -