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
Every preprocessing directive must begin with:
Anni [7]

Answer:

B. #

Explanation:

Every preprocessing directive must begin with the # character.

For example:

#define : Used to define a macro

#ifndef : Conditional evaluation of macro

#include : Used to include other preprocessor header file as part of the code

As we can see each of the directives begins with the # character. This is a signal to the preprocessor to interpret the subsequent keyword as a directive.

3 0
3 years ago
Darpa was created to
I am Lyosha [343]
Darpa is an agency that emerges technologies for the military. I would say B. investigate technologies. This is logical because they are working with technologies investigating how, where, and why they need to emerge in the first place.
7 0
3 years ago
People are still buying printed magazines?
BARSIC [14]
Yes, they are. 
Mostly dentists' offices, though.  
3 0
3 years ago
Develop a simple game that teaches kindergartners how to add single-digit numbers. Your function game() will take an integer n a
Lyrx [107]

Answer:

2 correct answer out of 3

5 0
3 years ago
Kim agrees. You get the equipment from the truck and begin working. Kim approaches you as you are installing the modem and is a
Angelina_Jolie [31]
Ask your friends if they are doing something wrong with your friends and friends
6 0
2 years ago
Other questions:
  • Jason is creating a webpage on the basic parts of a camera. He has to use a mix of both images and content for the web page to h
    11·1 answer
  • How long does it take a letter to arrive?
    9·1 answer
  • Suppose that you want to write a program that inputs customer data and displays a summary of the number of customers who owe mor
    14·1 answer
  • 60 POINTS!
    13·1 answer
  • Oiê gentee, bom dia O que você entende por cultura digital ??
    12·1 answer
  • Which of the following combines something you know, such as a password, with something you are (a biometric device such as a fin
    13·1 answer
  • PLEASE ANSWER!! If my pixel has an RGB value of (R - 150, G - 0, B - 100), what is the dominant value? Why?
    14·1 answer
  • How can injection attacks be prevented? Check all that apply
    6·2 answers
  • Find each of the following products using distributive property a) 735 × 16​
    12·1 answer
  • Desktop computers have a(n) ________ unit, located within the system unit, that plugs into a standard wall outlet, converts AC t
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!