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 8 of 8

Thread: What's difference between public class and abstract class?

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default What's difference between public class and abstract class?

    What's difference between public class and abstract class?


  2. #2
    Member
    Join Date
    Dec 2011
    Location
    United States
    Posts
    94
    My Mood
    Amused
    Thanks
    5
    Thanked 8 Times in 8 Posts

    Default Re: What's difference between public class and abstract class?

    Quote Originally Posted by Java95 View Post
    What's difference between public class and abstract class?
    There is a very quick and easy way to solve that question: Google. good luck.

  3. #3
    Junior Member
    Join Date
    Jan 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: What's difference between public class and abstract class?

    I only found the difference between an Interface and an Abstract class. But thanks anyways

  4. #4
    Member snowguy13's Avatar
    Join Date
    Nov 2011
    Location
    In Hyrule enjoying a chat with Demise and Ganondorf
    Posts
    339
    My Mood
    Happy
    Thanks
    31
    Thanked 48 Times in 42 Posts

    Default Re: What's difference between public class and abstract class?

    Use highlight tags to help others help you!

    [highlight=Java]Your prettily formatted code goes here[/highlight]

    Using these tags makes your code formatted, and helps everyone answer your questions more easily!




    Wanna hear something funny?

    Me too.

  5. #5
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: What's difference between public class and abstract class?

    Quote Originally Posted by Java95 View Post
    What's difference between public class and abstract class?
    Apples and oranges. Abstract classes can be public, but they don't have to be. Public classes can be abstract, but they don't have to be. So I guess that's more like comparing apples to fruit?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  6. #6
    Junior Member
    Join Date
    Sep 2011
    Location
    Hamburg, Germany
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Java95 View Post
    What's difference between public class and abstract class?
    An abstract class is kind of a template class which cannot be instantiated w/o adding some concrete code to it. A public class is simply a class that may be accessed by any other class w/o further restrictions.

  7. #7
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: What's difference between public class and abstract class?

    Quote Originally Posted by bkimminich View Post
    An abstract class is kind of a template class which cannot be instantiated w/o adding some concrete code to it.
    You sure about that definition?

    public class Test{
       public static void main(String... args){
          AbstractTest at = new AbstractTest(){};
          ExtendingClass et = new ExtendingClass();
       }
    }
     
    public abstract class AbstractTest{}
    public class ExtendingClass extends AbstractTest{}
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  8. #8
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: What's difference between public class and abstract class?

    Quote Originally Posted by Java95 View Post
    What's difference between public class and abstract class?
    As told earlier both are different concepts.

  9. #9
    Junior Member
    Join Date
    Jan 2013
    Posts
    20
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: What's difference between public class and abstract class?

    Hi,

    abstract class can contain zero or more abstract methods. It mean if a class contain abstract methods declare that class as abstract class by using abstract keyword. But whenever we apply the public on a class , it is possible to access that class inside and outside the package. That's why both are different.

Similar Threads

  1. Difference between extending and importing a class
    By TP-Oreilly in forum Java Theory & Questions
    Replies: 8
    Last Post: December 5th, 2011, 05:53 PM
  2. Abstract class
    By jeskoston in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 26th, 2011, 01:46 PM
  3. Public class help/error
    By Plural in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 11th, 2010, 05:22 PM
  4. abstract class
    By robinglow in forum Java Theory & Questions
    Replies: 2
    Last Post: August 20th, 2010, 01:36 AM
  5. abstract class
    By robinglow in forum AWT / Java Swing
    Replies: 2
    Last Post: August 20th, 2010, 01:36 AM