Sponsored Links


Results 1 to 2 of 2

Thread: Abstract classes vs. Interfaces in java

  1. #1
    Senior Member saneha's Avatar
    Join Date
    Apr 2011
    Posts
    266

    Question Abstract classes vs. Interfaces in java

    Sponsored Links1


    Following queries which creating problems to understand, which are

    1- give the brief detail theory about both the techniques.i.e. Abstract classes vs. Interfaces

    2- often you call the functions with the help of class name without using the object of the specific class, according to my concept of c++ we can only do this only when class declared as a static, i want to know that is it any concept in Java to manipulate the function in this style.


    Sponsored Links

  2. #2
    Administrator Vuhelper's Avatar
    Join Date
    Apr 2011
    Posts
    9,578
    We can not make instance of Abstract Class as well as Interface.

    Here are few differences in Abstract class and Interface as per the definition.



    Abstract class can contain abstract methods, abstract property as well as other members (just like normal class).



    Interface can only contain abstract methods, properties but we don’t need to put abstract and public keyword. All the methods and properties defined in Interface are by default public and abstract.



    When To Use Interfaces

    An interface allows somebody to start from scratch to implement your interface or implement your interface in some other code whose original or primary purpose was quite different from your interface. To them, your interface is only incidental, something that have to add on to the their code to be able to use your package.



    When To Use Abstract classes

    An abstract class, in contrast, provides more structure. It usually defines some default implementations and provides some tools useful for a full implementation. The catch is, code using it must use your class as the base. That may be highly inconvenient if the other programmers wanting to use your package have already developed their own class hierarchy independently. In Java, a class can inherit from only one base class.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. protected inheritance and abstract classes in C++ 2012
    By Vuhelper in forum C++ Programing
    Replies: 0
    Last Post: 01-14-2012, 04:48 PM
  2. Replies: 1
    Last Post: 05-02-2011, 06:33 AM
  3. Replies: 1
    Last Post: 04-28-2011, 08:55 PM
  4. what are classes in java 2011 ?
    By saneha in forum Java forum
    Replies: 1
    Last Post: 04-24-2011, 09:53 PM
  5. How to include java classes
    By saneha in forum Java forum
    Replies: 1
    Last Post: 04-24-2011, 08:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
-: Vuhelp Disclaimer :-
None of the files shown here are hosted or transmitted by this server. The links are provided solely by this site's users. The administrator's or staff of Vuhelp.net cannot be held responsible for what its users post, or any other actions of its users. You may not use this site to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms. If you have any doubts about legality of content or you have any suspicions, feel free to contact us.
Online Education | JhelumSoft