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
Bad White [126]
3 years ago
11

What will be the output of the following code?

Computers and Technology
1 answer:
saveliy_v [14]3 years ago
5 0

Answer:

The correct answer to this question is given below in the explanation section.

Explanation:

The correct answer to this question is : 4.

When you run this program in Java. The output produce by this program is 4

The given code is:

import java.util.ArrayList;

public class arrayList7

{

public static void main(String[] args) {

ArrayList one = new ArrayList ();

Integer count=3;

count=count+1;

one.add(2);

one.add(count);

System.out.println(one.get(1));

}

}

This code store the value in ArrayList one variable. It first adds 2 at zero indexes and 4 at first index.  When you print the value at index one, you will get the output 4. because the count variable contains 4. If you want to print 2, then you specify the print statement that prints the value at index zero. eg.

System.out.println(one.get(0));

You might be interested in
python (Business: check ISBN-10) An ISBN-10 (International Standard Book Number) consists of 10 digits: d1d2d3d4d5d6d7d8d9d10. T
iogann1982 [59]

Answer:

<em>The programming language is not stated;</em>

<em>However, I'll answer this question using C++ programming language</em>

<em>The program uses few comments; See explanation section for more detail</em>

<em>Also, the program assumes that all input will always be an integer</em>

#include<iostream>

#include<sstream>

#include<string>

using namespace std;

int main()

{

string input;

cout<<"Enter the first 9 digits of an ISBN as a string: ";

cin>>input;

//Check length

if(input.length() != 9)

{

 cout<<"Invalid input\nLength must be exact 9";

}

else

{

 int num = 0;

//Calculate sum of products

for(int i=0;i<9;i++)

{

 num += (input[i]-'0') * (i+1);    

}

//Determine checksum

if(num%11==10)

{

 input += "X";

 cout<<"The ISBN-10 number is "<<input;

}

else

{

 ostringstream ss;

 ss<<num%11;

 string dig = ss.str();

 cout<<"The ISBN-10 number is "<<input+dig;

}

}  

 return 0;

}

Explanation:

string input;  -> This line declares user input as string

cout<<"Enter the first 9 digits of an ISBN as a string: ";  -> This line prompts the user for input

cin>>input;  -> The user input is stored here

if(input.length() != 9)  { cout<<"Invalid input\nLength must be exact 9";  }  -> Here, the length of input string is checked; If it's not equal to then, a message will be displayed to the screen

If otherwise, the following code segment is executed

else  {

int num = 0; -> The sum of products  of individual digit is initialized to 0

The sum of products  of individual digit is calculated as follows

for(int i=0;i<9;i++)

{

num += (input[i]-'0') * (i+1);

}

The next lines of code checks if the remainder of the above calculations divided by 11 is 10;

If Yes, X is added as a suffix to the user input

Otherwise, the remainder number is added as a suffix to the user input

if(num%11==10)  {  input += "X";  cout<<"The ISBN-10 number is "<<input; }

else

{

ostringstream ss;

ss<<num%11;

string dig = ss.str();

cout<<"The ISBN-10 number is "<<input+dig;

}

}  

5 0
3 years ago
What font option will elevate part of the text to a higher level and decrease its size? A. Subscript
ra1l [238]
C.italic because it brings a higher attention but is smaller then the text its self <span />
5 0
3 years ago
How can I use the internet/social media to protect my identity?
sattari [20]
Don't show your face and don't put your name or location online? i'm confused by this question.
3 0
3 years ago
What is the benefit to displaying the merge codes in a document?
sergejj [24]

Answer:

The author will know where data will be inserted in the document.

Explanation:

5 0
3 years ago
Physical education is the body's ability to function effectively and efficiently without excessive farigue. TRUE/FALSE
Salsk061 [2.6K]

Answer: True

Explanation:

6 0
2 years ago
Other questions:
  • A technology _____ begins with the birth of a new technology and ends when that technology reaches its limits and dies as it is
    13·1 answer
  • Lucinda works at a recycling center. She noticed an increase in glass recyclables entering the center. She collects data regardi
    7·2 answers
  • What is a way to Procter your social security number and other sensitive information from identity theft
    9·1 answer
  • You just came back to your office from a meeting about is security.​ you've learned a few things about a​ "good" password, and y
    15·1 answer
  • Consider the partially-filled array named a. What does the following loop do? (cin is a Scanner object)int[] a = {1, 3, 7, 0, 0,
    6·1 answer
  • The merge sort algorithm sorts using what technique?
    8·1 answer
  • Thank you very much for your email. ...... was very interesting​
    15·1 answer
  • List all the components of a computer
    14·2 answers
  • Explain the bad effect and good effect of mobile phone and internet.<br>​
    15·2 answers
  • Name any three areas of of application of excel.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!