Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Dog {
- String name;
- int age;
- Dog(String n, int age) {
- name = n;
- this.age = age;
- }
- void bark() {
- System.out.println("Woof!");
- }
- void wakeTheNeighbors() {
- int i= 50;
- while (i > 0) {
- bark();
- i = i - 1;
- }
- }
- public static void main(String[] args) {
- Dog fido = new Dog("Fido", 5);
- // Assumed:
- System.out.println("bark()");
- fido.bark();
- System.out.println("wakeTheNeighbors()");
- fido.wakeTheNeighbors();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement