Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

abstracts

Posted on 2004-11-26
2
Medium Priority
?
413 Views
Last Modified: 2010-03-31
Hi all,

what exactly are abstracts, on what conditions are they used and how could they be used? Examples would be greatly appreciated. Thanks..
0
Comment
Question by:eturfclub
2 Comments
 
LVL 13

Expert Comment

by:petmagdy
ID: 12682499

Abstract is a class that can't be instantiated because it has one or more abstract method, Any number of Classes can extend this abstract and implment the abstract methods hence can be instantiated, refer to this article contains samples:

http://java.sun.com/docs/books/tutorial/java/javaOO/abstract.html
0
 
LVL 8

Accepted Solution

by:
rk_radhakrishna earned 2000 total points
ID: 12682516
abstract
----------
An formally unfinished class or method, marked with the keyword abstract. An abstact class is deliberatesly missing some or all of the method bodies. An abstract method is deliberately missing its method body. An abstract class is similar to an interface which is missing all the method bodies. An abstract class provides a base for someone to extend an actual class. You can't use new on abstract classes, but you can use abstract references, which always point to some extension of the abstract class. Interfaces are implicitly abstract as are alls their methods.

abstract class
----------------
A class that is missing definitions for one or more methods. You can't thus create an object of that class. You must first create a subclass and provide definitions for the abstract methods. Unlike interfaces, abstract classes may implement some of the methods. Though you can't instantiate an abstract class, you can invoke its static methods.

find some more information ............
http://www.javaworld.com/javaworld/javaqa/2001-04/03-qa-0420-abstract.html
http://java.sun.com/docs/books/tutorial/java/javaOO/abstract.html
http://www.codeguru.com/java/tij/tij0079.shtml

Simple Example
--------------------
import java.util.*;

abstract class Instrument4 {
  int i; // storage allocated for each
  public abstract void play();
  public String what() {
    return "Instrument4";
  }
  public abstract void adjust();
}

class Wind4 extends Instrument4 {
  public void play() {
    System.out.println(" plays test");
  }
  public String what() { return "Wind4"; }
  public void adjust() {}
}
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month15 days, 9 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question