0% found this document useful (0 votes)
27 views3 pages

Tugas Pemrograman Berorientasi Objek: Disusun Oleh: Nama: Alan Zuniargo Prabowo NIM: L2N009046

The document discusses object-oriented programming tasks in Indonesian. It provides two examples: 1) A simple program with a class called "senapan" (gun) that creates an object and prints its caliber, type, and mechanism attributes. 2) An inheritance example with a "seni" (art) class that creates an object from the "senirupa" (fine art) subclass, which extends the "graffiti" superclass and overrides the info() method to print attributes.

Uploaded by

Hendra Taufiq
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views3 pages

Tugas Pemrograman Berorientasi Objek: Disusun Oleh: Nama: Alan Zuniargo Prabowo NIM: L2N009046

The document discusses object-oriented programming tasks in Indonesian. It provides two examples: 1) A simple program with a class called "senapan" (gun) that creates an object and prints its caliber, type, and mechanism attributes. 2) An inheritance example with a "seni" (art) class that creates an object from the "senirupa" (fine art) subclass, which extends the "graffiti" superclass and overrides the info() method to print attributes.

Uploaded by

Hendra Taufiq
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

TUGAS PEMROGRAMAN BERORIENTASI OBJEK

DISUSUN OLEH : Nama NIM : Alan Zuniargo Prabowo : L2N009046

PROGRAM STUDI SISTEM KOMPUTER FAKULTAS TEKNIK UNIVERSITAS DIPONEGORO SEMARANG 2011

1. Program sederhana terdiri dari class dan object


public class senapan { String kaliber; String tipe; String mekanisme; public static void main ( String[]args ) senapan senjata = new senapan(); senjata.kaliber="sedang"; senjata.tipe="serbu"; senjata.mekanisme="otomatis"; System.out.println ("Kaliber senapan +senjata.kaliber); System.out.println ("Tipe senapan +senjata.tipe); System.out.println ("Mekanisme senapan +senjata.mekanisme); } } = " = " = "

2. Inheritance
public class seni { public static void main ( String[]args ) { senirupa art = new senirupa(); // membuat objek baru dari class senirupa art.info(); } } class graffiti { private String a = " mural "; public void info() { System.out.println (" "); System.out.println (" graffiti = "+a); } } class senirupa extends graffiti { private String b = " lukisan "; public void info(){ System.out.println (" ");

super.info(); System.out.println (" seni rupa } }

= "+b);

You might also like