tags:

views:

103

answers:

4
  public class Animal 
   {
    public Animal()
          {
             System.out.println("Animal");
          }
   }

  public class Mammal extends Animal
   {
    public Mammal()
          {
             System.out.println("Mammal");
          }
   }

Is this an object or a class? If not, what would be an example of an Object?

+6  A: 

These are classes.

new Animal() would be an object, i.e. an instance of a class.

tangens
+1  A: 

A class is the definition. An object is an instance of class.

Tim Cooper
+3  A: 

Both Animal and Mammal are classes.

Animal a = new Animal();

The code above will result in a reference, a, that refers to an object of type Animal. Since Mammal extends Animal, you'd also be allowed to write:

Animal a = new Mammal();

Your reference type would still be Animal, but this time it's referring to an object of type Mammal.

Bill the Lizard
A: 

The Theory of Forms typically refers to Plato's belief that the material world as it seems to us is not the real world, but only a shadow of the real world. Plato spoke of forms in formulating his solution to the problem of universals. The forms, according to Plato, are roughly speaking archetypes or abstract representations of the many types and properties (that is, of universals) of things we see all around us. Epistemology (From: wikipedia)

To explain it with Plato: The class is a form, 'a shadow'. The 'universals', those many types and properties are the objects.

Andreas_D