Preview

Object

Good Essays
Open Document
Open Document
1086 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Object
11. Compare and contrast abstract classes and interfaces. Why would you use an abstract class? Why would u use an interface?
-abstract class, ex: (public abstract class Employee{...}) -For related classes only, inheritance (last week examples) -extends keyword -contains both instance and static variables -contains both abstract and concrete methods only
An abstract class is only to be sub-classed (inherited from). In other words, it only allows other classes to inherit from it but cannot be instantiated. The advantage is that it enforces certain hierarchies for all the subclasses. In simple words, it is a kind of contract that forces all the subclasses to carry on the same hierarchies or standards.
-interface (public interface Payable{...}) -for unrelated classes (today examples) -contains only static variables -contains only abstract method
An interface is not a class. It is an entity that is defined by the word Interface. An interface has no implementation; it only has the signature or in other words, just the definition of the methods without the body. As one of the similarities to Abstract class, it is a contract that is used to define hierarchies for all subclasses or it defines specific set of methods and their arguments. The main difference between them is that a class can implement more than one interface but can only inherit from one abstract class
Similarities
-both does not allow object to be created
-both contain abstract method that must be override
-both exhibit a polymorphic behavior

Feature | Interface | Abstract class | Multiple inheritance | A class may inherit several interfaces. | A class may inherit only one abstract class. | Default implementation | An interface cannot provide any code, just the signature. | An abstract class can provide complete, default code and/or just the details that have to be overridden. | Access Modfiers | An interface cannot have access modifiers for the subs, functions, properties etc

You May Also Find These Documents Helpful

  • Satisfactory Essays

    Assignment 1 2015W

    • 491 Words
    • 3 Pages

    1. For the case you choose to analyze, answer each question one by one in paragraphs. The answers to the three questions should be logically connected.…

    • 491 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    Psy300 Week 8

    • 760 Words
    • 4 Pages

    • Describe the architectural differences between the object-oriented and structured designs. Which of the designs makes more sense to you? Why?…

    • 760 Words
    • 4 Pages
    Good Essays
  • Good Essays

    What words did you use to find this article? Artificial intelligence and robotics What type of article is this (research, summary, reflection, essay, etc.)? Essay Did this article include an abstract? Yes…

    • 951 Words
    • 28 Pages
    Good Essays
  • Good Essays

    9. A method that stores a value in a class’s field or in some other way changes the value of a field is known as a…

    • 1518 Words
    • 7 Pages
    Good Essays
  • Powerful Essays

    Begin a new page. Your abstract page should already include the page header as shown above. An abstract is a succinct summary of a longer piece of work, usually academic in nature, which is published in isolation from the main text and should therefore stand on its own and be understandable without reference to the longer piece. It should report the latter 's essential facts, and should not exaggerate or contain material that is not there. Its purpose is to act as a reference tool (for example in a library abstracting service), enabling the reader…

    • 2558 Words
    • 11 Pages
    Powerful Essays
  • Satisfactory Essays

    Howto Set Up Apa Style

    • 407 Words
    • 2 Pages

    * Abstract (Please note that longer APA research paper must include an abstract. However for this course one is not necessary?…

    • 407 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Enc 150

    • 813 Words
    • 4 Pages

    Directions: Please answer each of the following questions in a paragraph for each. Explain your thoughts with theory and examples where applicable.…

    • 813 Words
    • 4 Pages
    Good Essays
  • Good Essays

    YOU MUST EMPHASIZE CLASS NOTES AND OUTLINES! You may use your book, but your answers will not be correct if you do not provide responses which reflect the class lectures/discussions.…

    • 1464 Words
    • 6 Pages
    Good Essays
  • Satisfactory Essays

    Java Programming I Exam

    • 912 Words
    • 4 Pages

    Locating and repairing all syntax errors is part of the process of ____ a program.…

    • 912 Words
    • 4 Pages
    Satisfactory Essays
  • Good Essays

    has seen that total abstraction need not be limited in this manner. While Mondrian had…

    • 593 Words
    • 3 Pages
    Good Essays
  • Powerful Essays

    OOP Assigment 1 Sit 1

    • 4788 Words
    • 20 Pages

    Inheritance is when a class (subclass) has the same attributes and methods of another class (parent class); this is done by creating class from an existing class. While a subclass has properties derived for the parent class, it can also have properties of its own.…

    • 4788 Words
    • 20 Pages
    Powerful Essays
  • Good Essays

    The Paper

    • 484 Words
    • 2 Pages

    In the story The Pact by Drs.Sampson Davis, George Jenkins and Rameck Hunt demonstrate how three young friends can stay together when the times get hard and fulfill their lifelong dream of being doctor’s. If they can accomplish their dreams and making it a reality so, can you by hard work and determination it will come true. This book shows how if you keep your mind set, you can go far and achieve greatness. This will help explain how they “beat the odds”.…

    • 484 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    Found Objects

    • 389 Words
    • 2 Pages

    As I stumble my way through life, I found the one thing that the thing that is very important to me my family. Nothing compares how greatly family impacts people. I can’t imagine myself having a career that doesn’t involve helping my family or others’. I want family to be a part of my life, regardless if I am being an orthodontist for children or working in finance making sure that families are financially stable. There are many reasons why family is important to me. All of those reasons define who I am and who I will be in the future.…

    • 389 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    The key to this assignment is to draw on important concepts from the class. The following questions will help to get you started. (not all question may be applicable to your particular paper). You should have AT LEAST 5 Concepts.…

    • 378 Words
    • 2 Pages
    Satisfactory Essays
  • Best Essays

    Embodiment

    • 3084 Words
    • 13 Pages

    Evaluate the proposition that society has no right to call itself sane with reference to the role of anorexia and bulimia nervosa?…

    • 3084 Words
    • 13 Pages
    Best Essays

Related Topics