0% found this document useful (0 votes)
55 views7 pages

Cara Membuat Program Di Website W3school

The document provides instructions for creating a Java program on the w3schools website using either a computer or mobile device. The steps are: 1. Open a browser and go to the w3schools website 2. Select Java and then try it yourself 3. Type or copy/paste sample Java code into the online editor and click run to execute the program.

Uploaded by

Katep wae
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views7 pages

Cara Membuat Program Di Website W3school

The document provides instructions for creating a Java program on the w3schools website using either a computer or mobile device. The steps are: 1. Open a browser and go to the w3schools website 2. Select Java and then try it yourself 3. Type or copy/paste sample Java code into the online editor and click run to execute the program.

Uploaded by

Katep wae
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Cara Membuat Program di Website w3school.

com

A. Dengan Menggunakan Komputer atau Laptop


1. Buka browser
2. Kunjungi alamat website w3school.com dengan alamat https://www.w3schools.com/

3. pilih java
4. kemudian pilih tryit yourself

5. tampilan awal

6. ketik listing program berikut

class Polimorphism {

public static void main(String[ ] args) {

cetakObyek(new Balok());
cetakObyek(new PersegiPanjang());
cetakObyek(new BangunDatar());
cetakObyek(new Object());
}

public static void cetakObyek(Object obyek) {


System.out.println(obyek);
}

} // Akhir kelas Polimorphism

class Balok extends PersegiPanjang {


public String toString() {
return "Mempunyai sisi panjang, lebar dan tinggi";
}
}

class PersegiPanjang extends BangunDatar {


public String toString() {
return "Mempunyai sisi panjang dan lebar";
}
}

class BangunDatar extends Object {


public String toString() {
return "Mempunyai berbagai bentuk";
}
}
[15:04, 6/12/2021] Andri Saksono: class Animal {
public void animalSound() {
System.out.println("The animal makes a sound");
}
}

class Pig extends Animal {


public void animalSound() {
System.out.println("The pig says: wee wee");
}
}

class Dog extends Animal {


public void animalSound() {
System.out.println("The dog says: bow wow");
}
}

class Main {
public static void main(String[] args) {
Animal myAnimal = new Animal();
Animal myPig = new Pig();
Animal myDog = new Dog();

myAnimal.animalSound();
myPig.animalSound();
myDog.animalSound();
}
}

7. kemudian klik RUN


B. Dengan Menggunakan Smartphone atau Handphone
1. Buka browser
2. Kunjungi alamat Kunjungi alamat website w3school.com dengan alamat
https://www.w3schools.com/

3. pilih java
4. pilih tryit yourself

5. ketik program berikut, kemudian klik RUN.

class Animal {
public void animalSound() {
System.out.println("The animal makes a sound");
}
}

class Pig extends Animal {


public void animalSound() {
System.out.println("The pig says: wee wee");
}
}

class Dog extends Animal {


public void animalSound() {
System.out.println("The dog says: bow wow");
}
}

class Main {
public static void main(String[] args) {
Animal myAnimal = new Animal();
Animal myPig = new Pig();
Animal myDog = new Dog();

myAnimal.animalSound();
myPig.animalSound();
myDog.animalSound();
}
}

You might also like