Question

Question 7 0 / 10 points What is a Java Interface and what role can it have in developing Data Structures? Support your answeQuestion 9 0 / 10 points Describe the basic operations that can be performed on a stack. Write an algorithm (using bullet poi

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

Question 7
A java interface is nothing but a collection of abstract methods. Whenever a class implements an interface, it is inheriting the abstract methods inside that interface. And later on, provide its own definition of that method.
The main reasons why interfaces are used:

  • It enables the support of multiple inheritance in Java.
  • We can achieve loose coupling using this.
  • It is used to achieve abstraction.

Role of interface in data structures:
An interface also acts as an abstract data type which only defines the operations supported by the corresponding data structures, but doesn't tell how the data structure implements the specified operations. In other words, it only provides us the details regarding operations supported by it, the arguments accepted and the kind of values returned by it. A data structure thus, can implement this interface to provide definitions to the abstract methods inside it. Those abstract methods were only declaring the methods but the definitions are now given by the classes, which are implementing them. Thus same interface can have multiple implementations based on the classes that are implementing them.

One of the best examples of this is the List interface which is used in Java to maintain ordered collection of elements.

  • ArrayList
  • LinkedList
  • Stack

These are some of the classes which implement List interface. Each one of them use the abstract methods in their own way as required.

Add a comment
Know the answer?
Add Answer to:
Question 7 0 / 10 points What is a Java Interface and what role can it...
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
  • Question 9 0 / 10 points Describe the basic operations that can be performed on a...

    Question 9 0 / 10 points Describe the basic operations that can be performed on a stack. Write an algorithm (using bullet points or a description, not Java or C) which shows how to remove an item from a stack that is implemented as an array. No text entered - This question has not been graded. The correct answer is not displayed for Written Response type questions. Question 10 0 / 10 points What are the main characteristics of a...

  • 1: Next Page Page 8 of 10 2: Question 8 (10 points) What is meant by...

    1: Next Page Page 8 of 10 2: Question 8 (10 points) What is meant by a static data structure? In your opinion, what are the advantages and disadvantages of such structures? Do you feel that the advantages outweigh the disadvantages?

  • Interfaces 1. What is inside an interface definition? What does a class do to an interface...

    Interfaces 1. What is inside an interface definition? What does a class do to an interface and what keyword is involved? How does a class do this to an interface (what should we find in the class)? Can an interface have a generic parameter? How do you instantiate an interface as an object? What methods can’t you use on an interface type? Abstract Data Types 2. What does an ADT define? Does an ADT specify programming language and/or data structures...

  • This is a reminder that this is not a C++ or Java course. It is a...

    This is a reminder that this is not a C++ or Java course. It is a Data Structures course. This means that you are to write your own code unless otherwise specified in the assignment. The use of built in data structures types like linked lists, stacks, queues, trees, maps, graphs etc. is prohibited and will result in a 60% reduction in your grade. Furthermore, the lecture material presents code that should be used to get you started. Any data...

  • SHORT ANSWER QUESTIONS Part 1 Classes Abstraction: What is Abstraction in terms of representation? Specifically what...

    SHORT ANSWER QUESTIONS Part 1 Classes Abstraction: What is Abstraction in terms of representation? Specifically what choices does one make when creating a class that is an example of Abstraction? Encapsulation: What is encapsulation? What is information hiding? What does a public interface to a class consist of (not in the sense of actual java interfaces but what the client uses to manipulate objects of the class) What is an object of a class? What is the constructor? How do...

  • QUESTION 1 In a tree, a ____ is a node with successor nodes. root child descendent...

    QUESTION 1 In a tree, a ____ is a node with successor nodes. root child descendent parent sibling QUESTION 2 In a tree, the ____ is a measure of the distance from a node to the root. count degree branch height level QUESTION 3 Which of the following is not a characteristic of a binary search tree? Each node has zero, one, or two successors. The preorder traversal processes the node first, then the left subtree, and then the right...

  • Stacks and Java 1. Using Java design and implement a stack on an array. Implement the...

    Stacks and Java 1. Using Java design and implement a stack on an array. Implement the following operations: push, pop, top, size, isEmpty. Make sure that your program checks whether the stack is full in the push operation, and whether the stack is empty in the pop operation. None of the built-in classes/methods/functions of Java can be used and must be user implemented. Practical application 1: Arithmetic operations. (a) Design an algorithm that takes a string, which represents an arithmetic...

  • In java 0 0 1 Hạshing Lab 1. Given the following key values, show what the...

    In java 0 0 1 Hạshing Lab 1. Given the following key values, show what the data structures would look like after insertions 27 53 13 10 138 109 49 174 26 24 (no preprocessing necessary: pk=key) a. Linear array of 10 elements using division hashing b. Bucket hashing of 10 elements (N=10) and the linear-quotient collision path algorithm ip = (px) %N N= 13, 4k+3 prime = 19 Array: Array: LOHashing: 1. ip = pk %N 1 2 2....

  • Project 2 Due April 15° 11:59pm. You could use an the implementation. y of the following programm...

    Project 2 Due April 15° 11:59pm. You could use an the implementation. y of the following programming language to do CH Java Python You will implement a student class with data members (ID, gender, DoB, Major, GPA). You will implement a gradebook class using (Inherit from) TWO of the following data structures. Array Singly Linked list ea Binary Search Tree You need to at least implement the followin gradebook. operations for the 1) FindHighestGPA0 returns the student who has the...

  • JAVA 3 LECTURE REVIEW PLEASE NEED ANSWERS ASAP. DUE IN AN HOUR!!! Question 12 points The...

    JAVA 3 LECTURE REVIEW PLEASE NEED ANSWERS ASAP. DUE IN AN HOUR!!! Question 12 points The best-case performance for a shell sort is: --- O(1) O(n2)   O(n) O(n log n)   Signaler cette question Question 22 points The best-case performance for an array of n items using insertion sort is: --- O(n2)   O(n) O(1) there is no best-case Signaler cette question Question 3 2 points A recursive method that processes a chain of linked nodes --- uses the first node in...

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