Justwondering
Member
- May 14, 2008
- 96
- 0
- 6
Here is an example:
public class Animal{
//constructor
//properties
//methods
}
The above is just a blueprint.
In another class you might make an instance of the Animal, or an object:
Animal myPet = new Animal();
The object is called myAnimal. It is a reference to an Animal class.
Let's try to think of some properties and methods that would go in Animal. Then we will write the Animal class in this thread.
I wrote this:
public class Dog extends Animal;
public void makeNoise() System.out.println("roof roof!");
come to find out this is a sub class. Just having a little trouble grasping this object orientated.
What I wanted to do first is write methods inside Animal. Can someone give me an example?
public class Animal{
//constructor
//properties
//methods
}
The above is just a blueprint.
In another class you might make an instance of the Animal, or an object:
Animal myPet = new Animal();
The object is called myAnimal. It is a reference to an Animal class.
Let's try to think of some properties and methods that would go in Animal. Then we will write the Animal class in this thread.
I wrote this:
public class Dog extends Animal;
public void makeNoise() System.out.println("roof roof!");
come to find out this is a sub class. Just having a little trouble grasping this object orientated.
What I wanted to do first is write methods inside Animal. Can someone give me an example?