PBO 6 - Grouping Object dan Sifat Object

Collection

Java Collections adalah framework yang menyediakan sebuah tempat untuk menyimpan dan memanipulasi sekumpulan objek. Adapun kegiatan yang dapat dilakukan pada sebuah data seperti pencarian, pengurutan, memasukkan, menghapus dapat dilakukan oleh Java Collections. Java Collection secara  sederhana merupakan sebuah objek. Kerangka kerja Java Collection menyediakan dalam bentuk interfaces(Set, List, Queue, Deque dll) dan untuk class (ArrayList, Vector, LingkedList, PriorityQueue, HashSet, LinkedHashSet, TreeSet dll). Hirarki Java Collenction terlihat pada gambar berikut ini:



Materi



Sifat Obyek-Overloading

Method Overloading adalah sebuah kemampuan yang membolehkan sebuah class mempunyai 2 atau lebih method dengan nama yang sama, yang membedakan adalah parameternya.

Pada method overloading perbedaan parameter mencakup :

  1. Jumlah parameter
  2. Tipe data dari parameter
  3. Urutan dari tipe data parameter

Method Overloading juga dikenal dengan sebutan Static Polymorphism. Berikut ini contoh Class yang melakukan Overloading.

1:  class MyClass {  
2:    int height;  
3:    MyClass() {  
4:     System.out.println("bricks");  
5:     height = 0;  
6:    }  
7:    MyClass(int i) {  
8:     System.out.println("Building new House that is "  
9:     + i + " feet tall");  
10:     height = i;  
11:    }  
12:    void info() {  
13:     System.out.println("House is " + height  
14:     + " feet tall");  
15:    }  
16:    void info(String s) {  
17:     System.out.println(s + ": House is "  
18:     + height + " feet tall");  
19:    }  
20:  }  
21:  public class MainClass {  
22:    public static void main(String[] args) {  
23:     MyClass t = new MyClass(0);  
24:     t.info();  
25:     t.info("overloaded method");  
26:     //Overloaded constructor:  
27:     new MyClass();  
28:    }  
29:  }  


Sifat Obyek-Overriding

Method overriding merupakan method yang parrent class yang ditulis kembali oleh subclass. Aturan dari method overriding pada Java :

Parameter yang terdapat pada method overriding di subclass harus sama dengan parameter yang terdapat pada parent class.
Aturan hak akses, hak akses method overriding di subclass tidak boleh lebih ketat di bandingkan dengan hak akses method pada parent class.
public class Binatang {
    public void begerak(){
        System.out.println("Binatang bergerak sesuai kemampuannya");
    }
    public void berkembangBiak(){
        System.out.println("Binatang berkembang biak sesuai kemampuannya");
    }

}

public class Mamalia extends Binatang {
    //overriding method parent class
    public void begerak(){
        System.out.println("Mamalia bergerak sebagian besar dengan kakinya");
    }    
    public void berlari(){
        System.out.println("Sebagian Mamalia dapat berlari");
    }
}


public class PenggunaanOverriding {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Binatang b = new Binatang();
        Mamalia m = new Mamalia();
        Binatang bm = new Mamalia();
        
        b.begerak();
        m.begerak();
        bm.begerak();
        bm.berkembangBiak();
    }
}



Materi dalam bentuk Power Point



Video




Latihan

Buat Implementasi kodenya 


Pengumpulan Tugas


Referensi : Buku Object First Java

Absensi Kelas A



Share this

Related Posts

Previous
Next Post »

227 komentar

komentar «Oldest   ‹Older   201 – 227 of 227   Newer›   Newest»
October 28, 2020 at 7:35 PM delete

Nama : Daffa Amanullah Setyawan
NRP : 05111940000071
Kelas : PBO C
Link : Tugas4 (Auction System)

Reply
avatar
October 28, 2020 at 8:16 PM delete

Nama: Timotius Wirawan
NRP: 05111940000161
Kelas: PBO C
Link:
1. Collection https://timotiuswirawan.blogspot.com/2020/10/tugas-4-collection.html
2. Auction System https://timotiuswirawan.blogspot.com/2020/10/tugas-4-auction-system.html

Reply
avatar
October 28, 2020 at 8:24 PM delete

Nama : Dewangga Dharmawan
NRP : 05111940000029
Kelas : PBO C
Tugas : Collection dan Auction System

Reply
avatar
October 28, 2020 at 11:36 PM delete This comment has been removed by the author.
avatar
October 28, 2020 at 11:37 PM delete This comment has been removed by the author.
avatar
October 28, 2020 at 11:41 PM delete This comment has been removed by the author.
avatar
October 28, 2020 at 11:43 PM delete

Nama : Ahmad Lamaul Farid
NRP : 05111940000134
Kelas : PBO C
Tugas : Tugas Pertemuan 4-Auction System

Reply
avatar
October 28, 2020 at 11:45 PM delete

Nama: Fayha Syifa Qalbi
NRP: 05111940000185
Kelas:PBO-C
Link Tugas4: https://syifaaqalbii.wordpress.com/2020/10/29/task-iv/

Reply
avatar
October 28, 2020 at 11:48 PM delete This comment has been removed by the author.
avatar
October 29, 2020 at 12:03 AM delete

Nama : Fidhia Ainun Khofifah
NRP : 05111940000203
Kelas : PBO C
Link : Tugas 4

Reply
avatar
October 29, 2020 at 1:08 AM delete

Nama : Husnan
NRP : 05111940007002
Kelas: PBO C
Tugas: Auction System

Reply
avatar
October 29, 2020 at 1:36 AM delete

Nama : Aimar Wibowo
NRP : 05111940000034
Kelas : PBO C
Link Auction Sysytem : https://aimarwibowo46.blogspot.com/2020/10/tugas-4-membuat-auction-system-kelas.html
Link Collection : https://aimarwibowo46.blogspot.com/2020/10/tugas-4-collection-kelas-pbo-c.html

Reply
avatar
October 29, 2020 at 8:46 AM delete

Nama : Gian Ega Wijaya
Nrp : 05111940000214
Kelas : PBO C
Tugas
Grouping Object : https://gianhuman.wordpress.com/2020/10/29/tugas-pbo/
Auction System : https://gianhuman.wordpress.com/2020/10/29/tugas-pbo-2/

Reply
avatar
November 3, 2020 at 9:44 AM delete

Nama : Refaldyka Galuh Pratama
NRP : 05111940000209
Kelas : PBO C
Tugas :
1. Collection Class
2. Auction System

Reply
avatar
November 4, 2020 at 9:03 AM delete

Nama : Aflah Hilmy
NRP : 05111940000177
Kelas : PBO C
Link :
Link Tugas 4

Reply
avatar
November 4, 2020 at 6:47 PM delete

Nama : Daffa Tristan Firdaus
NRP : 05111940000006
Kelas : PBO C
Tugas : Link Tugas 4

Reply
avatar
November 4, 2020 at 8:44 PM delete This comment has been removed by the author.
avatar
November 4, 2020 at 8:45 PM delete

Nama : Muhammad Farrel Abhinaya
NRP : 05111940000173
Kelas : PBO C
Link Tugas : https://mfarrelabinaya.blogspot.com/2020/11/auction-project-pada-bluej.html

Reply
avatar
November 4, 2020 at 8:46 PM delete

Nama : Fais Rafii Akbar Hidiya
NRP : 05111940000026
Kelas : PBO C
TUGAS 4 AUCTION

Reply
avatar
November 4, 2020 at 9:35 PM delete

Nama : Albert Filip Silalahi
NRP : 05111940000116
Kelas: PBO C
Link : Tugas 4 - Auction Project

Reply
avatar
November 5, 2020 at 1:05 AM delete

Nama : Avind Pramana Azhari
NRP : 05111940000226
Kelas : PBO C
Tugas : Tugas 4

Reply
avatar
November 15, 2020 at 6:15 PM delete

Nama : Andymas Narendra Bagaskara
NRP : 05111940000192
Kelas : PBO-C
Tugas : https://tugaspborendra.blogspot.com/2020/10/tugas-minggu-keempat-kelas-pbo-c.html

Reply
avatar
November 17, 2020 at 12:22 AM delete

Nama : Kevin Ashil F
Kelas : PBO B
Tugas : Auction System

Reply
avatar
November 24, 2020 at 3:21 PM delete

Nama : ICHSANUL AULIA
NRP : 0511184007001
Kelas : PBO B
hhttps://ichsanulaulia.blogspot.com/2020/10/auction-aplication-pbo-tugas-3-oleh.html

Reply
avatar
December 26, 2020 at 7:15 AM delete

Nama : Yusuf Anfasya
NRP : 05111940000077
Kelas : PBO C
Tugas : Link Tugas

Reply
avatar
January 12, 2021 at 1:36 AM delete

Nama: Bagaskoro Kuncoro Ardi
NRP: 05111940000048
Kelas: PBO C
https://pbobagaska.blogspot.com/2020/10/tugas-pbo-c-minggu-ke-4-auction-project.html
https://pbobagaska.blogspot.com/2021/01/tugas-pbo-c-minggu-ke-4-latihan-contoh.html

Reply
avatar
January 12, 2021 at 1:37 AM delete

Nama : Fajar Satria
NRP : 05111940000083
Kelas : PBO C
Link : Java Collection dan Auction System

Reply
avatar
«Oldest   ‹Older   201 – 227 of 227   Newer›   Newest»