Results 1 to 6 of 6

Thread: What is Abstract methods?

  1. #1
    Join Date
    Dec 2009
    Posts
    68

    What is Abstract methods?

    Hi friends,

    I am new to the programming. Currently I am learning Java programming. But I am getting troubled while understanding the concept of 'Abstract methods'. I want to be aware about the use of 'Abstract methods' in java programming. I wonder if you are able to help me know about the 'Abstract methods'. I would greatly appreciate you any help over 'Abstract methods'.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: What is Abstract methods?

    In Pascal keywords abstract or virtual are used in the class type declaration at the end of the line to specify what will be virtual or abstract methods. An interface is a Java class which comprises only abstract methods and doesn't implement any field there is to say methods without declaration. It serves as a formalism for classes that implement it. The abstract methods of the interface are accessible only from classes that implement the interface and these classes must be redefined by implementing.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: What is Abstract methods?

    Hi friend, Please refer following example of 'Abstract methods':
    Code:
    public abstract class Shape1
    {
        
     //...Class implementation
    
        public abstract void Draw1(int xm, int ym) //...Abstract method declaration
    
        {
            
        } 
    }
    
    
    public abstract class Shape2D1 : Shape1
    
    { //Class implementation
    
        
    }
    
    public class Cricle1 : Shape2D1
    {
        
        public override void Draw(int xm, int ym)
        {
            
        }
    
    }

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Re: What is Abstract methods?

    A class abstract describes the behavior Common and full a set objects, even if some of these behaviors can be located at this level must still declare them (abstract). Do not declare abstract methods that would not make sense for all subclasses. Java will not create an instance of abstract method, it is logical if we could do then we would get an object not fully implanted. A class may, of course, be declared abstract same if it contains no methods abstract.

  5. #5
    Join Date
    Apr 2008
    Posts
    1,948

    Re: What is Abstract methods?

    Hi,

    Below given example depict you the use of abstract methods:
    Code:
    abstract class Abter1
    {
        abstract void Abter1();
        public long repeat(int c){
            long start = System.currentTimeMillis();
            for (int i=0; i<c; i++) benchmark();
            return(System.currentTimeMillis()-start);
        }
    }
    class MDAbter1 extends Abter1
    {
        void Abter1(){};
        public static void main(String[] args)
    {
            int d=Integer.parseInt(args[0]);
            long time = new MethodBenchmark().repeat(c);
            System.out.println(c+" methodes en "+time+" millisecondes");
        }
    }

  6. #6
    Join Date
    May 2008
    Posts
    2,012

    Re: What is Abstract methods?

    Implement all the abstract methods is always inherited which is referred as concrete class. Abstract class must not be instantiated. This type of class naturally extend to use it. A subclass of this class is abstract only if it still does not define all abstract methods it inherits. The methods that states without giving them an implementation must be declared abstract with keyword abstract. Abstract class which adds a service to its abstract methods.

Similar Threads

  1. Table and abstract classes
    By TechGate in forum Software Development
    Replies: 5
    Last Post: 03-03-2010, 10:49 AM
  2. Use of abstract classes
    By ScarFace 01 in forum Software Development
    Replies: 5
    Last Post: 25-01-2010, 09:07 AM
  3. Abstract class in Java
    By SoftWore in forum Software Development
    Replies: 3
    Last Post: 07-11-2009, 01:58 PM
  4. Abstract Classes in PHP5
    By nonose in forum Software Development
    Replies: 2
    Last Post: 16-06-2009, 02:33 PM
  5. Abstract class and Interface in .net
    By RogerFielden in forum Software Development
    Replies: 3
    Last Post: 04-05-2009, 06:07 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,538,538.40960 seconds with 17 queries