• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

CLASSES !! :)

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI EVERYONE;
CAN ANYONE TELL ME WHAT IS THE DIFFERENCE BETWEEN
"ABSTRACT CLASS" AND "ANONYMOUS CLASS" AND ALSO IF THERE IS
ANY DIFFERENCE BETWEEN THE TWO BASED ON THEIR RUNTIME AND COMPILE TIME CHARACTERISITICS??
ankush!!
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Abstract class is the class which can not be instentiated.
i.e. you can not create a new object of an abstract class.Abstract class can only be extended.
Anonymes class is the class within another class(i.e. Inner Class) with no class name specified.
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Classes are abstract due to two reason
1.one of their methods is abstract
2.Due to keyword abstract
They can't be instantiated but we can make their reference
Anonymous classes are classes with no names but they must have a supertype(superclass or superInterface)
Example
button.addMouseListener(new MouseAdapter{
public void mouseClicked(MouseEvent me)
{
System.out.println("Clicked");
}
});

Here the anonymous class is having no name but is an instance and its super class is WindowAdapter( which happens to be abstract)
Thanks
Steven

 
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anonymous Classes
Some classes that you define inside a method do not need a name. A class defined in this way without a name is called an anonymous class. An anonymous class gives you a convenient way to avoid having to think up trivial names for classes
The class is instantiated and declared in the same place.
The declaration and instantiation takes the form
new Xxxx ()
{
//body
}

where Xxxx is an interface name.
An anonymous class cannot have a constructor. Since you do not specify a name for the class, you cannot use that name to specify a constructor.
Abstract Classes
Sometimes, a class that you define represents an abstract concept and, as such, should not be instantiated. An abstract class is a class that can only be subclassed.
An abstract class may contain abstract methods, that is, methods with no implementation. In this way, an abstract class can define a complete programming interface, thereby providing its subclasses with the method declarations for all of the methods necessary to implement that programming interface. However, the abstract class can leave some or all of the implementation details of those methods up to its subclasses.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic