Question

Exercise 1: Understanding Object Oriented Design Principles [Please Answer clearly using python, No java code only...

Exercise 1: Understanding Object Oriented Design Principles [Please Answer clearly using python, No java code only python]

What are the differences between an abstract class and an interface class? Present 02 examples one of an abstract class and one of an interface class in python

0 0
Add a comment Improve this question Transcribed image text
Answer #1

the main difference between abstract class and interface class :
interface class contains only method declarations and not implementations
abstract class contains may contain abstract declarations and concrete implementations or both
An interface can contain only method declarations.
An abstract class can contain both method declarations (abstract methods) and method implementations (concrete methods).
Python abstract class example:
class AbstractClass:#abtract class
def do_something(self):#abstrct method
pass
def work(self):#method with implementation
print("Hello")
class B(AbstractClass):
pass
a = AbstractClass()
a.work()
b = B()
Python interface class example:
class AbstractClass:#abtract class
def do_something(self):#abstrct method
pass
class B(AbstractClass):
pass
a = AbstractClass()
a.work()
b = B()

Add a comment
Know the answer?
Add Answer to:
Exercise 1: Understanding Object Oriented Design Principles [Please Answer clearly using python, No java code only...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • IN JAVA Design and code a class hierarchy that demonstrates your understanding of inheritance and polymorphism....

    IN JAVA Design and code a class hierarchy that demonstrates your understanding of inheritance and polymorphism. Your hierarchy should contain at least 5 classes and one driver program that instantiates each type of object and runs multiple methods on those objects. Inheritance and Polymorphism must be apparent in the project. Please keep in mind that polymorphism was in chapter 37, so you will need to have read both chapters to understand what goes into this project. Bonus if you add...

  • Java is an object-oriented programming language that enables us to define classes and to instantiate them...

    Java is an object-oriented programming language that enables us to define classes and to instantiate them into objects. These objects then call each other’s methods to implement the behavior of the application. The Unified Modeling Language (UML) is an object-oriented visual notation to document the design of object-oriented classes. For this discussion, you will practice designing a Java class called Course, drawing a UML class diagram for the Course class, and then implementing the Course class in Java code. Review...

  • Explain the following object-oriented(OO) concepts with the aid of code examples (either C++ or Java): Inheritance Over-riding . Over-loading Describe any differences between C++ and Java in how the...

    Explain the following object-oriented(OO) concepts with the aid of code examples (either C++ or Java): Inheritance Over-riding . Over-loading Describe any differences between C++ and Java in how these OO concepts are implemented? 3(c) 17 Marks] Describe C++ namespaces using a code example. Describe Java packages, again using a code example. How do C++ namespaces compare to Java packages? 3(d) [5 Marks] What are inline methods in C++/Java? Explain the terms accessor and mutator. Explain the following object-oriented(OO) concepts with...

  • Use Java please... Activity 1. Suppose we want to have an object-oriented design for an invoicing...

    Use Java please... Activity 1. Suppose we want to have an object-oriented design for an invoicing system, that includes invoices, one or more line items in each invoice, address of the invoice, list of products, etc. Try to design this system by indicating the required classes, responsibilities of each class, and the collaborating classes to fulfill each responsibility, and draw the CRC cards as well as UML diagram of the classes and their relationships. Then, indicate the methods of each...

  • 1) Using the Object-Oriented Programming Paradigm,implement the necessary code in Python creating a ‘Car’ class with...

    1) Using the Object-Oriented Programming Paradigm,implement the necessary code in Python creating a ‘Car’ class with a constructor that stores all the Car information (ID, MAKE, MODEL, YEAR , COLOR, MILEAGE, PRICE_TO_DEALER, SALE_PRICE, PROFIT) as attributes. 2) Implement and add the following methods to the ‘Car' class in Question 1. a) necessary getter methods b) necessary setter methods c) method to display all the information to the screen d) a method to calculate the profit

  • Write a python program using Object Oriented and do the following: 1. create class "cat" with...

    Write a python program using Object Oriented and do the following: 1. create class "cat" with the following properties: name, age (create constructor method: def __init__) 2. create class "adopter" with the following properties: name, phone 3. create class "transaction" with these properties: adopter, cat (above objects) cat1 = "puffy, 2" adopter1 = "Joe, 123" Test your program: Joe adopts puffy. Print: "Per Transaction 1 <joe> has adopted <puffy>" this can only be done with object oriented programming, no way...

  • This Java program must use classes and object-oriented design (OOD) as I'm in a more advanced...

    This Java program must use classes and object-oriented design (OOD) as I'm in a more advanced Java class. (Sales Commission Calculator) A large company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who sells $5000 worth of merchandise in a week receives $200 plus 9% of $5000, or a total of $650. You’ve been supplied with a list of the items sold...

  • SOLVE IN PYTHON: Exercise #1: Design and implement class Circle to represent a circle object. The...

    SOLVE IN PYTHON: Exercise #1: Design and implement class Circle to represent a circle object. The class defines the following attributes (variables) and methods: A private variable of type double named radius to represent the radius. Set to 1. Constructor Methods: Python : An overloaded constructor method to create a default circle. C# & Java: Default Constructor with no arguments. C# & Java: Constructor method that creates a circle with user-specified radius. Method getRadius() that returns the radius. Method setRadius()...

  • USE JAVA, PYTHON OR C TO WRITE AN ALGORITHM FOR THIS EXERCISE: . Chocolate bar puzzle...

    USE JAVA, PYTHON OR C TO WRITE AN ALGORITHM FOR THIS EXERCISE: . Chocolate bar puzzle Given an n × m chocolate bar, you need to break it into nm 1 × 1 pieces. You can break a bar only in a straight line, and only one bar can be broken at a time. Design an algorithm that solves the problem with the minimum number of bar breaks. What is this minimum number? Justify your answer by using the properties...

  • Java Programming Questions (Multiple Choice) ** Please only answer if you know it, not just copy...

    Java Programming Questions (Multiple Choice) ** Please only answer if you know it, not just copy and paste from another user. Please explain the answer. 1) Given code: public abstract class A{ } public class B extends A { } The following code sequence would correctly create an object reference of class A holding an object reference for an object of class B: A c; c = new B(); TRUE FALSE ---------------------------------------------------------------------------------------------------------------------------------------- 2) After the following code sequence is executed,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT