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
ipn [44]
3 years ago
10

Questions 5 - 7 refer to the following code: public class Whatchamacallit { private double price; private String title; public W

hatchamacallit() { this (0, "none"); } public Whatchamacallit(double p, String t) { price = 0; if (p > 0) { price = p; } title = t; } public String toString() { return title + " costs $" + price; } } The following code segment appears in another class: ArrayList list = new ArrayList(); list.add(new Whatchamacallit()); list.add(new Whatchamacallit(3.5, "book")); list.add(new Whatchamacallit(-17, "CD")); list.add(new Whatchamacallit(18.95, "sweater")); list.add(new Whatchamacallit(5, "notebook")); /* Missing Code */ Suppose the following line is used to replace /* Missing Code */. System.out.println(list.get(0)); What is printed as a result of executing the code segment?
Computers and Technology
1 answer:
viva [34]3 years ago
3 0
Some code formatting is required to understand this question

<span>Whatchamacallit {
   private double price;
   private String title;
   public Whatchamacallit()
   {
     this (0, "none");
   }
   public Whatchamacallit(double p, String t)
   {
     price = 0;
     if (p > 0)
     {
         price = p;
      }
      title = t;
    }
  public String toString()
   { return title + " costs $" + price; }
}

The following code segment appears in another class:

  ArrayList list = new ArrayList();
  list.add(new Whatchamacallit());
  list.add(new Whatchamacallit(3.5, "book"));
  list.add(new Whatchamacallit(-17, "CD"));
  list.add(new Whatchamacallit(18.95, "sweater"));
   list.add(new Whatchamacallit(5, "notebook"));
  /* Missing Code */
Suppose the following line is used to replace /* Missing Code */. System.out.println(list.get(0)); 

The answer is 'none</span> costs $0'

This is because the line:
'System.out.println(list.get(0))'
gets the first item (index 0) in the array, which was :
'list.add(new Whatchamacallit()) '
and Whatchamacallit() sets price = 0 and title = 'none' in the class Whatchamacallit

The specific output of the  'get(0)' is because of the 'toString()' method in 
Whatchamacallit
 
You might be interested in
What two choices do you have when you open the Remote tab of the System Settings?
andre [41]

Answer:

remote assistance and remote desktop

Explanation:

^

4 0
3 years ago
Please help with simple python code!
BlackZzzverrR [31]

Answer:

use the 'if "inspira" in sampleString' to find the word, then append to a new string which is the final string

Explanation:

4 0
3 years ago
Write a function which will ask users to enter numbers and return the largest number.
kherson [118]

Answer:

#include<stdio.h>

int GetLargest()

{

int a[100],n,largest;

printf("Enter number of elements\n");

scanf("%d",&n);

printf("Enter elements\n");

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

scanf("%d",&a[i]);

i=0;

largest=a[i];

while(i<n)

{

i++

if(a[i]>largest)

largets=a[i];

}

return largest;

}

void main(){

int largest;

largest=GetLargest();

printf("Largest Number is %d",largest);

}

Explanation:

Here we define one function "GetLargest". This function reads n number of elements and finds the largest number among the n elements. Here we took one array and assumed first element is the largest element. if any element of the array is greater that that element we make that as larger and continues.at the end we are getting largest element in the n numbers and returning that to the main.

8 0
4 years ago
PLEASE HELP!!
Elden [556K]

Answer:

Paquete de red o paquete de datos es cada uno de los bloques en que se divide la información para enviar, en el nivel de red. Por debajo del nivel de red se habla de trama de red, aunque el concepto es análogo. En todo sistema de comunicaciones resulta interesante dividir, la información a enviar, en bloques de un tamaño máximo conocido. Esto simplifica el control de la comunicación, las comprobaciones de errores, la gestión de los equipos de encaminamiento (routers), etcétera.

Al igual que las tramas, los paquetes pueden estar formados por una cabecera, una parte de datos y una cola. En la cabecera estarán los campos que pueda necesitar el protocolo de nivel de red; en la cola, si la hubiere, se ubica normalmente algún mecanismo de comprobación de errores.

Explanation:spero  teyaudee

8 0
3 years ago
Two variables, num and cost have been declared and given values: num is an integer and cost is a double. Write a single statemen
sweet [91]

// Writing a C++ Program for the given senario

#include<iostream>         // Using input and output stream

using namespace std;       // Using standard namespace

// Main function

int main(){

int num = 10;             // int num initialized with 10

double cost =1000;       // double cost initialized with 1000

/*

Cout is stream in C++ that uses << symbol to output anything on the screen and as the problem says we need to output both numbers on a line, i have used multiple << because on cout streams you are allowed to send one element at a time.

Also, endl is a keyword in C++ that ends the line after output for the cout stream is finished.

*/

cout<< num << " " << cost <<endl;

// Return 0 means telling the compiler to terminate the //program

return 0;

}

3 0
3 years ago
Other questions:
  • • Why does a lunar eclipse last longer than a solar eclipse?
    15·1 answer
  • Web browsers are used to browse the world wide web.
    5·2 answers
  • Example of hard ware that computers on a network can share are he operating and the web browser? True or false
    7·2 answers
  • Write a statement that compares the values of score1 and score2 and takes the following actions. When score1 exceeds score2, the
    7·1 answer
  • Create a method to search an un-ordered array of integers for a value, if the value is found return the index of its position in
    10·1 answer
  • (Game Design) Creating and manipulating data structures is one of the primary functions of a development environment.
    12·2 answers
  • 5. The image file format most suited for photographs is what? *
    8·2 answers
  • Sergio needs to tell his team about some negative feedback from a client. The team has been
    5·1 answer
  • Complete the procedure for creating a new appointment by selecting the correct answers from the drop-down menus.
    11·1 answer
  • What is a good theme statement for the short Pixar film "bao"?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!