Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Our List class was abstract and had no constructors. Because of one of these fac

ID: 3576585 • Letter: O

Question

Our List class was abstract and had no constructors. Because of one of these facts, we cannot instantiate the class Which causes this effect? Additionally, explain the purpose of making a class abstract. ArrayList and LinkedList extended the List class. Explain what this forced those classes to do. Because ArrayLut and LinkedList extended List, the following commands are legal in Java. List ourList - new LinkedList(); ourList.append(3); ourList - new ArrayList; ourList.prepend(7); Explain why this is allowed when ourList is neither a LinkedList nor an ArrayList.

Explanation / Answer

9)
The abstract class cannot be instantiated because Abstract Class is a skeleton structure i.e. they are not fully complete classes.
Purpose of abstraction is to hide the implementation details from the user and only provide the functionality to the user.
In other words, the user will only know what the object does instead of how it does it.
10)
ArrayList and LinkedList extended the lists class means they had inherited the properties of List class.
This class provides a skeletal implementation of the List interface to minimize the effort required to implement this interface backed by a "random access" data store . For sequential access data (such as a linked list), AbstractSequentialList should be used in preference to this class.
SO when we want to implement unmodifiable list, the programmer needs only to extend this class and provide implementations for the get(int) and size() methods.

11)
The above code design implements basic Object Oriented design principle.
When we use a reference of a parent type to refer to an instance of a sub-type we get a lot of flexibility.
when you do
List ourList = new LinkedList<Object>();
you get more liberty to change LinkedList to ArrayList without changing elsewhere in the code. So it basically gives you the power to change the underlying implementation without affecting other places in code.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote