Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: Difference between interface and abstract class?

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    1
    My Mood
    Happy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool Difference between interface and abstract class?

    Hi friends this is one of most java interview question.So, we will see clear difference between
    abstract class and interface.

    you may visit this link to see clear view

    Interface:-


    1) If we don't know any thing about implementation just we have requirement specification then we should go for interface.

    2) Every method present inside interface is by default public & abstract

    3) The following modifiers are not allowed for interface methods, those are:
    stritfp, protected,static,native,private,final,synchronized


    4) Every variable present inside interface is public, static final , bydefault wheather we are declare or not.

    5) For the interface variables we can't declare the following modifiers, those are:
    private, protected, transient, volatile

    6) For the interface variables compulsary we should perform initialization at the time of declaration only

    7) Inside interface we can't take instance& static blocks

    8) Inside interface we can't take constructor.

    Abstract Class:-


    1) If we are talking about implementation but not completly(partial implementation) then we should go
    for abstract class


    2) Every method present inside abstract class need not be public & abstract. we can take concrete
    methods also.

    3) There are no restrictions for abstract class method modifier i.e, we can use any modifier

    4) Abstract class variables need not be public, final static.

    5) There are no restriction for abstract class variable modifiers

    6) For the abstract class variables there is no restriction like performing initialization at the time of declaration.

    7) Inside abstract class we can take static block & instance blocks

    8) Inside abstract class we can take constructor.
    Last edited by copeg; January 11th, 2014 at 01:37 PM. Reason: link removed


Similar Threads

  1. Java Abstract class and Interface issues in a code
    By John234 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 5th, 2013, 08:51 PM
  2. [SOLVED] Abstract method in a non-abstract class
    By bassie in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 2nd, 2012, 10:27 AM
  3. abstract VS interface
    By anis.laghaei in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 27th, 2012, 12:07 PM
  4. [SOLVED] Sahaja here. Need guidance. Interface and Abstract class
    By sahaja in forum Java Theory & Questions
    Replies: 2
    Last Post: July 4th, 2012, 04:43 PM
  5. What's difference between public class and abstract class?
    By Java95 in forum Java Theory & Questions
    Replies: 7
    Last Post: January 24th, 2012, 06:37 AM

Tags for this Thread