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

  • 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
  • Satisfactory Essays

    [Type the abstract of the document here. The abstract is typically a short summary of the contents of the document. Type the abstract of the document here. The…

    • 508 Words
    • 3 Pages
    Satisfactory Essays
  • 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
  • Good Essays

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

    • 593 Words
    • 3 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

    What is an abstract? How is an abstract helpful in refining your search? (75 to 100 words)…

    • 436 Words
    • 2 Pages
    Satisfactory 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
  • 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
  • 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
  • Good Essays

    Research Paper Abstract

    • 691 Words
    • 3 Pages

    A research paper abstract is an essence of the research paper itself, written for a specific purpose and in very precise words and would only be written if asked for. Often professors ask students to write an abstract which would explain in simple and precise terms, the purpose of the research and the conclusion. Sometimes, before going through the research paper itself, readers often prefer to go through the research paper abstracts which help them in choosing which research paper to pursue further. A typical abstract should provide the following information:…

    • 691 Words
    • 3 Pages
    Good 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