a)
Abstract class:
An abstract class is a class which may or may not include abstract methods and cannot be instantiated but rather can be sub classed.
Legal abstract class:
The conditions for a class to be considered as legal abstract class are mentioned below:
- If a class includes abstract methods, then the class must be declared as abstract.
- The abstract method that is declared within the abstract class must be declared without braces and followed by a semicolon.
Interface:
Interface is a reference type in Java, which contains a collection of abstract methods.
An interface needs to the follow certain conditions such as:
- One cannot instantiate an interface.
- Interfaces do not contain any constructors.
- All methods present in the interface are abstracts.
- An interface does not contain any instance field.
- An interface cannot be extended by a class.
b)
Abstract class:
An abstract class is a class which may or may not include abstract methods and cannot be instantiated but rather can be sub classed.
Legal abstract class:
The conditions for a class to be considered as legal abstract class are mentioned below:
- If a class includes abstract methods, then the class must be declared as abstract.
- The abstract method that is declared within the abstract class must be declared without braces and followed by a semicolon.
Interface:
Interface is a reference type in Java, which contains a collection of abstract methods.
An interface needs to the follow certain conditions such as:
- One cannot instantiate an interface.
- Interfaces do not contain any constructors.
- All methods present in the interface are abstracts.
- An interface does not contain any instance field.
- An interface cannot be extended by a class.
c)
Abstract class:
An abstract class is a class which may or may not include abstract methods and cannot be instantiated but rather can be sub classed.
Legal abstract class:
The conditions for a class to be considered as legal abstract class are mentioned below:
- If a class includes abstract methods, then the class must be declared as abstract.
- The abstract method that is declared within the abstract class must be declared without braces and followed by a semicolon.
Interface:
Interface is a reference type in Java, which contains a collection of abstract methods.
An interface needs to the follow certain conditions such as:
- One cannot instantiate an interface.
- Interfaces do not contain any constructors.
- All methods present in the interface are abstracts.
- An interface does not contain any instance field.
- An interface cannot be extended by a class.
d)
Abstract class:
An abstract class is a class which may or may not include abstract methods and cannot be instantiated but rather can be sub classed.
Legal abstract class:
The conditions for a class to be considered as legal abstract class are mentioned below:
- If a class includes abstract methods, then the class must be declared as abstract.
- The abstract method that is declared within the abstract class must be declared without braces and followed by a semicolon.
Interface:
Interface is a reference type in Java, which contains a collection of abstract methods.
An interface needs to the follow certain conditions such as:
- One cannot instantiate an interface.
- Interfaces do not contain any constructors.
- All methods present in the interface are abstracts.
- An interface does not contain any instance field.
- An interface cannot be extended by a class.
e)
Abstract class:
An abstract class is a class which may or may not include abstract methods and cannot be instantiated but rather can be sub classed.
Legal abstract class:
The conditions for a class to be considered as legal abstract class are mentioned below:
- If a class includes abstract methods, then the class must be declared as abstract.
- The abstract method that is declared within the abstract class must be declared without braces and followed by a semicolon.
Interface:
Interface is a reference type in Java, which contains a collection of abstract methods.
An interface needs to the follow certain conditions such as:
- One cannot instantiate an interface.
- Interfaces do not contain any constructors.
- All methods present in the interface are abstracts.
- An interface does not contain any instance field.
- An interface cannot be extended by a class.
Want to see the full answer?
Check out a sample textbook solutionChapter 13 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version, Student Value Edition (11th Edition)
- Write a Program in java Define an interface named Shape with a single method named area that calculates the area of the geometric shape: public double area(); Implement the Shape interface for Rectangle, Circle and Triangle class. Implement a class CalculateAreas that has a function that takes shape type array of objects and builds an array of (double values) values for each corresponding shapesarrow_forwardA library wants to manage its collection of books and authors more efficiently. They would like to create a Python program to help with this task. The following requirements need to be implemented: Create an Author class with the attributes: name, dob (date of birth), and nationality. The class should have a __str__ method to represent the author in a user-friendly format. Create a Book class with the following attributes: title, author (an instance of the Author class), publication_date, and price. Also, include a class variable all_books that keeps a list of all book instances created.The Book class should have: A __str__ method to represent the book in a user-friendly format. A __eq__ method to compare two books. Two books are considered the same if they have the same title and author. A __lt__ method to compare two books based on their publication dates. A class method get_all_books that returns a list of all books in the library. A static method most_expensive_book that takes…arrow_forwardA library wants to manage its collection of books and authors more efficiently. They would like to create a Python program to help with this task. The following requirements need to be implemented: Create an Author class with the attributes: name, dob (date of birth), and nationality. The class should have a __str__ method to represent the author in a user-friendly format. Create a Book class with the following attributes: title, author (an instance of the Author class), publication_date, and price. Also, include a class variable all_books that keeps a list of all book instances created.The Book class should have: A __str__ method to represent the book in a user-friendly format. A __eq__ method to compare two books. Two books are considered the same if they have the same title and author. A __lt__ method to compare two books based on their publication dates. A class method get_all_books that returns a list of all books in the library. A static method most_expensive_book that takes…arrow_forward
- Describe one advantage of requiring a class to implement an interface.arrow_forwardonly in java not in java c++ 1. Define an interface named Shape with a single method named area that calculates the area of the geometric shape: public double area(); 2. Implement the Shape interface for Rectangle, Circle and Triangle class. 3. Implement a class CalculateAreas that has a function that takes shape type array of objects and builds an array of (double values) values for each corresponding shapesarrow_forwardT/F 1. Interface classes cannot be extended but classes that implement interfaces can be extended.arrow_forward
- 1. Why do you need to implement all the methods of an interface in class which implements an interface?arrow_forwardCS Java Program (NEED HELP WITH THE ACTUAL CODING PART): For this project, you will create an application for a zoo. You will need to create a class that implements the iAnimal interface (provided below), and use one other class for an additional animal that implements the iAnimal interface as well (provided below). Modify the animal classes that you will use for this project so they implement Java’s comparable or comparator interface. You will also need a Main Class that will provide a user interface for this application. This can be a console-based interface. Tasks can be performed in one or more methods as needed. The Main Class should have one or more methods that handle these tasks: Create a new instance (object) of each of the animal classes and pass the user input as arguments to the object's mutator methods to set the private instance data for the appropriate animal class. Create an ArrayList of type iAnimal and add the new instance created in task 1 to the ArrayList. Before…arrow_forwardDoes it make sense to implement each and every method of an interface while doing so?arrow_forward
- Pick the incorrect statement: O A class can implement more than one interface O A class can extend more than one classes O An interface can extend more than one interfaces O An interface cannot extend a classarrow_forward15. Create an interface MessageEncoder that has a single abstract method encode (plainText), where plainText is the message to be encoded. The method will return the encoded message.arrow_forwardWrite a program in Java that handles the order list for an online retailer. Your program should contain a minimum of three classes: Order Class Display Class Main Class Create a Order Class that uses a queue to hold the orders in the order they were taken. The queue should contain the customer last name, order number, and order total cost. Create a Display Class that will store a copy of the order queue in two arrays. Each array will contain the order list but one will be sorted by name and the other sorted by order number. When a order is taken and stored in the Order Class the program will update theDisplay Class arrays automatically sort them in descending order using quick sort and outputs the the contents to the console upon each entry of new data. Create a Main Class that will handle operator data input and when an order is added or removed, the program will update the Order Class and Display Class. The user will be presented a menu to add a order, remove a order and display…arrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT