1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vagabundo [1.1K]
3 years ago
15

Add the function min as an abstract function to the class arrayListType to return the smallest element of the list. Also, write

the definition of the function min in the class unorderedArrayListType and write a program to test this function.
Computers and Technology
1 answer:
marshall27 [118]3 years ago
7 0

Answer:

The Answer is given in the explanation section, See detailed explanations as comments within the code.

Explanation:

import java.util.ArrayList;

import java.util.Collections;

import java.util.List;

// The abstract class with the abstract method

public abstract class arrayListType {

   public abstract int smallestElement();

}

//Class to implement the the abstract method

class unorderedArrayListType{

   public  int smallestElement(){

       //Create the list of Intitial capacity of 5

       List<Integer> myList = new ArrayList<Integer>(5);

       //Add Elements to the list

       myList.add(3);

       myList.add(4);

       myList.add(1);

       myList.add(6);

       myList.add(7);

     

       //FInd the smallest integer and return it

       int smallestInt = Collections.min(myList);

       return smallestInt;

}

}

//Testing the class with a main method

class Testing {

   public static void main(String[] args) {

       // Creating an instance of the class unorderedArrayListType

   unorderedArrayListType list1 = new unorderedArrayListType();

   //Calling the method to print the smallest Integer in the List

       System.out.println(list1.smallestElement());

   }

}

You might be interested in
How are Action Buttons different than hyperlinks?
ipn [44]

Actions buttons are different than hyperlinks in many ways.

2)They are predefined shapes.

<u>Explanation:</u>

Action buttons are predefined shapes in the PowerPoint and can be used for moving between the slides of the presentation and for referring to the hyperlinks as well.

Action buttons have a predefined shape and that shape can be used to set the functionality of that particular button as a convention. Action buttons make up a strong presentation.

Action buttons can be invoked by clicking on them or just hovering over them and various sound effects can also be added on both the events to make the presentation more engaging and attractive.

8 0
3 years ago
What do the stapedius and gluteus maximus have in common?<br> this is a science question
jenyasd209 [6]

Answer:

What do the stapedius and gluteus maximus have in common? They move the hips and thighs. They are attached to bones. They are the largest muscles.

Explanation:

5 0
3 years ago
Read 2 more answers
PLEASE HELP ASAP!!!!!!!!!!!
Bingel [31]

Answer:

True

Explanation:

3 0
3 years ago
Read 2 more answers
If your presentation uses a background, your text should _____.
Klio2033 [76]

your text should work well with the background.

It's very important for the text to be readable.

5 0
3 years ago
Read 2 more answers
A particular triplet of bases in the coding sequence of DNA is AGT. The corresponding codon for the mRNA is a. AGT. b. TCA. c. U
morpeh [17]

Answer:

(c) UCA

Explanation:

mRNA is a type of RNA it is also called messenger RNA it has temporary copy of information which is found in DNA. If the particular triplet of bases in the coding sequence of DNA is AGT then corresponding codon for RNA will be UCA which is given in option

so from above discussion it is clear that (C)will be the correct answer

8 0
3 years ago
Other questions:
  • What would make this comparison statement False? Complete with the appropriate relational operator. "G" _____= "G"
    10·1 answer
  • The buses that connect peripheral (typically input and output) devices to the motherboard are often called expansion buses. ____
    5·1 answer
  • Write a program to output the following quote by Edsger W. Dijkstra: "Computer Science is no more about computers than astronomy
    9·2 answers
  • How can presentation software be used in a business or professional setting? Choose all that apply.​
    8·1 answer
  • You're familiar with the story of Hansel and Gretel, so when you decide to go exploring you always make sure to keep track of wh
    14·1 answer
  • In C, developers may access arrays via bracketed syntax like Java or by using * dereferencing notation. The following assignment
    5·1 answer
  • Which of the following is considered part of the process in the systems thinking example of a TPS?
    6·1 answer
  • Which statement about bump mapping and normal mapping is true?
    9·1 answer
  • Selective colleges choose to have in-person meetings to learn more about the applicants. These meetings are called:
    8·2 answers
  • Autocad has _____ different ways to use the three point method if drawing and arc
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!