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
What is jcl language on the mainframe?
Pavel [41]
Job Control Language on the mainframe is the name for scripting language used on IBM mainframe operating system to instruct how to start a subsystem.
5 0
4 years ago
James is an intern in a film production company. On his first day, James’ boss, Monica, tells him, “Before anything else, let me
bija089 [108]

Answer:

cinematography is the answer broodaaa

6 0
3 years ago
Which teamwork characteristic motivates your team members to perform better?
scoundrel [369]
Maybe Encouragement? I don't know, are there any choices to choose from?
4 0
3 years ago
Read 2 more answers
State 3 file formats explain them in an understanding manner apart from Microsoft word and PDF
natita [175]

Answer:

Hope below explanations are enough.

Explanation:

1. JPEG (or JPG) - Joint Photographic Experts Group

JPEGs might be the most common file type you run across on the web, and more than likely the kind of image that is in your company's MS Word version of its letterhead. JPEGs are known for their "lossy" compression, meaning that the quality of the image decreases as the file size decreases.

You can use JPEGs for projects on the web, in Microsoft Office documents, or for projects that require printing at a high resolution. Paying attention to the resolution and file size with JPEGs is essential in order to produce a nice looking project.

2. PNG - Portable Network Graphics

PNGs are amazing for interactive documents such as web pages, but are not suitable for print. While PNGs are "lossless," meaning you can edit them and not lose quality, they are still low resolution.

The reason PNGs are used in most web projects is that you can save your image with more colors on a transparent background. This makes for a much sharper, web-quality image.

3. GIF - Graphics Interchange Format

GIFs are most common in their animated form, which are all the rage on Tumblr pages and in banner ads. It seems like every other day we have a new Grumpy Cat or Honey Boo Boo animated GIF. In their more basic form, GIFs are formed from up to 256 colors in the RGB colorspace. Due to the limited number of colors, the file size is drastically reduced.

This is a common file type for web projects where an image needs to load very quickly, as opposed to one that needs to retain a higher level of quality.

4. TIFF - Tagged Image File

A TIF is a large raster file that doesn't lose quality. This file type is known for using "lossless compression," meaning the original image data is maintained regardless of how often you might copy, re-save, or compress the original file.

Despite TIFF images' ability to recover their quality after manipulation, you should avoid using this file type on the web -- it can take forever to load. TIFF files are also commonly used when saving photographs for print.

5. PSD - Photoshop Document

PSDs are files that are created and saved in Adobe Photoshop, the most popular graphics editing software ever. This type of file contains "layers" that make modifying the image much easier to handle. This is also the program that generates the raster file types mentioned above.

The largest disadvantage to PSDs is that Photoshop works with raster images as opposed to vector images.

6 0
3 years ago
Prompt the user to input five pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9). Store the jer
tiny-mole [99]

Answer:

  1. import java.util.Scanner;
  2. public class Main {
  3.    public static void main (String [] args) {
  4.        int jersey_num [] = new int[5];
  5.        int rating [] = new int[5];
  6.        Scanner inStream = new Scanner(System.in);
  7.        for(int i=0; i < 5; i++){
  8.            System.out.print("Enter player " + (i+1) + "'s jersey number:");
  9.            jersey_num[i] = inStream.nextInt();
  10.            System.out.print("Enter player " + (i+1) + "'s rating:");
  11.            rating[i] = inStream.nextInt();
  12.        }
  13.        System.out.println("ROSTER");
  14.        for(int j=0; j < 5; j++){
  15.            System.out.println("Player " + (j+1) + "-- Jersey number: " + jersey_num[j] + ", Rating: " + rating[j]);
  16.        }
  17.    }
  18. }

Explanation:

The solution code is written in Java. Firstly create two array, jersey_num and rating, with int type. This is to hold the five pairs of numbers input by user (Line 6 -7).

Next, create a for loop that run for 5 iterations and in each iteration prompt user to input jersey number and rating (Line 11 -17). The input number and rating will be set to the array, jersey_num and rating, respectively.

Next, print the title "Roster" (Line 19).

Create another for loop to display the five input pair of values (Line 21 - 23).

3 0
3 years ago
Other questions:
  • The bit width of the LRU counter for a 32 KB 16-way set associative cache with 32 Byte line size is
    13·1 answer
  • BITS wants to store information about the supervisors, including their supervisor number and the relationship to consultants. Su
    15·1 answer
  • Which type of software should he use to restrict his information from going out to these websites?
    12·2 answers
  • What component of a computer system holds the operating system when the computer is not running
    6·2 answers
  • ​In addition to joint application development, another popular user-oriented method is _____, which resembles a condensed versio
    14·1 answer
  • Spreadsheets will be displayed as tables in presentations.True or False?
    6·2 answers
  • TOPIC-PYTHON
    8·2 answers
  • Fallon is a new student on campus. Everywhere she goes, she is asked for her 12-digit student number. To memorize her new studen
    10·1 answer
  • What is the advantage of video conferecing
    13·2 answers
  • Rachel wants to copy eight rows of data from one spreadsheet to another. She opens the spreadsheet, highlights the appropriate d
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!