Output the number of tails using the constant array

Assignment Help JAVA Programming
Reference no: EM13853953

Question 1 As part of a bank account implementation, there is an account class and a checking account class. These two classes should be related by:

polymorphism
abstract classes
both composition and inheritance
inheritance
composition

Question 2 When using OOP, which of the following terms refers to a mechanism for a behavior, basically how it's implemented?

composition
inheritance
polymorphism
dynamic binding

Question 3 To access an element in an Array object,

Use the ArrayList's get() method.
Use the ArrayList's element() method.
Individual elements in an ArrayList can't be accessed without doing a sequential query getSequential(), returning every element up to and including the element requested.
Use square brackets around an index value.

Question 4 To access an element in an ArrayList object,

Use square brackets around an index value.
Use the ArrayList element() method.
Use the ArrayList get() method.
Individual elements in an ArrayList can't be accessed without doing a sequential query getSequential(), returning every element up to and including the element requested.

Question 5 What term below is defined as a message that tells the program that something has happened?

an interaction
a listener
an action
an event

Question 6 Which item below is defined as an object?

A String
An Array
All of the above
An ArrayList

Question 7 When a text-box-enter event occurs, which method and parameter are required to handle this type of action? (1 point)

actionEvent with an actionperformed parameter
actionListener with an interfaceID parameter
windowListener with an eventID parameter
actionPerformed with an actionEvent parameter

Question 8 Which class includes the setTitle and setSize methods?

JFrame
JWindow
JBox
JOptionpane

Question 9 Before utilizing the binary search method, __________ must be done to the array?

indexing
splitting
sorting
importing

Question 10 Which layout manager implements a one-compartment layout scheme?

GridlessLayout
GridBagLayout
GridLayout
FlowLayout
BorderLayout

Question 11 What is the default layout manager for a JFrame window?

GridBagLayout
GridLayout
FlowLayout
GridlessLayout
BorderLayout

Question 12 To call the superclass constructor, super() must be the first line in a constructor.

True
False

Question 13 Method overriding is when a method has the same name, same sequence of parameter types, and the same return type as a method in a superclass.

True
False

Question 14 Type casting, also known as promotion is considered an implicit conversion.

True
False

Question 15 An abstract method declaration should always be defined as public as it is meant to be inherited into a subclass to be correctly used.

True
False

Question 16 When using parseInt() to convert a string to a number, NumberFormatException is thrown if a non-integer argument is found.

True
False

Question 17 enableEdit() is used to allow a user to edit the contents of a JTextField.

True
False

Question 18 Write the statement to print to the screen the 6th element of the array defined below?
Integer [ ] priceList = new Integer [10];

Question 19 Declare and initialize an ArrayList of type Double and call this ArrayList stocks.

Question 20 Write the code on a single line to display the dialog box below.

Error! Filename not specified.

Question 21 Write the code on a single line to display the input box below. Save the results into a variable called "input".

Error! Filename not specified.

Question 22 Declare (do not initialize) two arrays:

1. One array called "myNumbers" will hold the values: 1.23, 3.14, 5.18, 82, 2.56. The array should not have any additional empty elements.
2. One array called "myNames" will hold the values: Tom, Bob, John, Steve. The array should not have any additional empty elements.
Proper syntax is required

Question 23 Assume that this code fragment compiles and runs. What is its output? As always, be precise when showing your output.
public static void main(String [] args)
{
int x = 3;
int xf = 0;

if (x == 0 || x == 1)
{
xf = 1;
}
else
{
xf = 1;
for (int i=2; i<=x; i++)
{
xf *= i;
}
}
System.out.println("Results are: " + xf);

Question 24 Assume that this program compiles and runs. Assume that the user enters 5 6 (separated by a space) for input. What is the output? As always, be precise when showing your output.
import java.util.Scanner;
public class TryCatchQuestion
{
public static void main(String [] args)
{
Scanner stdIn = new Scanner(System.in);
System.out.println("Please enter 2 numbers seperated by a space");
try
{
System.out.println("Output: " + stdIn.nextInt() / stdIn.nextInt());
}
catch (NumberFormatException e)
{
System.out.println("Number Format Exception");
}
catch (ArithmeticException e)
{
System.out.println("Division by zero");
}
catch (Exception e)
{
System.out.println("Other Exception");
}
}//end main
}//end TryCatchQuestion

Question 25 Assume that this program compiles and runs. Assume that the user enters 5 0 (separated by a space) for input. What is the output? As always, be precise when showing your output.

import java.util.Scanner;
public class TryCatchQuestion
{
public static void main(String [] args)
{
Scanner stdIn = new Scanner(System.in);
System.out.println("Please enter 2 numbers seperated by a space");
try
{
System.out.println("Output: " + stdIn.nextInt() / stdIn.nextInt());
}
catch (NumberFormatException e)
{
System.out.println("Number Format Exception");
}
catch (ArithmeticException e)
{
System.out.println("Division by zero");
}
catch (Exception e)
{
System.out.println("Other Exception");
}
}//end main
}//end TryCatchQuestion

Question 26 Assume that this program compiles and runs. Assume that the user enters 5 six (separated by a space) for input. What is the output? As always, be precise when showing your output.
import java.util.Scanner;
public class TryCatchQuestion
{
public static void main(String [] args)
{
Scanner stdIn = new Scanner(System.in);
System.out.println("Please enter 2 numbers seperated by a space");
try
{
System.out.println("Output: " + stdIn.nextInt() / stdIn.nextInt());
}
catch (NumberFormatException e)
{
System.out.println("Number Format Exception");
}
catch (ArithmeticException e)
{
System.out.println("Division by zero");
}
catch (Exception e)
{
System.out.println("Other Exception");
}
}//end main
}//end TryCatchQuestion

Question 27 Provide code that adds "Hello!" and "Goodbye." messages to the JFrame window so that the resulting window looks like this:
Error! Filename not specified.

You may assume that the JFrame window has been created using its default layout manager. Provide only two statements - one statement creates "Hello!" and adds it to the window and one statement creates "Goodbye." and adds it to the window. Do not provide extra code. In particular, you should not provide code for window settings (size, title, etc.), and you should not provide code for a listener. (3 points)

Question 28 Provide the code for a class called Coin.java that implements the main method provided below.
public static void main(String [] args)
{
Coin toss = new Coin();
for (int x = 0; x < 1000; x++)
toss.flip();
Coin.results();
}//end main
When the program runs, the following random output should be produced: (numbers will vary as are random)
Heads: 494
Tails: 506

Program specific requirements:

• Style is require but comments are NOT required. 1 pt
• Include appropriate import statements for your file. 1 pt
• Utilize a constant class array to hold "Heads" and "Tails" 1 pt
• Declare a class ArrayList called flips that will hold integer values, 0 for heads and 1 for tails 1 pt
• Create a flips method that performs the following: 4 pts
o Initializes an instance of the Random class and a random variable
o Stores a random variable either 0 or 1
o Store the random number in the flips ArrayList
• Create a results method that performs the following: 6 pts
o Declare variable to hold number of heads flipped
o Utilize a for loop to iterate through the ArrayList (do NOT hard code the size here)

For each iteration, increment the result from the ArrayList into a variable called heads

o Output the number of Heads using the constant array for the "Heads" heading along with the number of heads flipped
o Output the number of Tails using the constant array for the "Tails" heading along with the number of tails calculated from the size of the array minus the number of heads

Reference no: EM13853953

Questions Cloud

Entrant is better off with or without ability to withdraw : In the text, we considered a sequential move game in which an entrant was considering entering an industry in competition with an incumbent firm. Consider now that the entrant, if fought, has the possibility of withdrawing from the industry (at a los..
Characteristics of perception : What are the 6 characteristics of perception? If team members share those perceptions, how likely is it that the team will succeed in whatever goals they set
What is the maximum amount per unit the company would : what is the maximum amount per unit the company would be willing to pay to the outside manufacturer?
Research paper on these topic- orientation training topic : Choose Orientation Training topic and write a 500 word research paper on these topics. Include a detailed bibliography in APA format with the paper
Output the number of tails using the constant array : Assume that this program compiles and runs. Assume that the user enters 5 0 (separated by a space) for input. What is the output. As always, be precise when showing your output. Output the number of Tails using the constant array for the "Tails" h..
How many units will manager of the psf division purchase : How many units of Part Y34 will the manager of the PSF Division purchase, either internally or externally?
What seems to be causing the collapse of values : Ethics begins at home. What moral and ethical problems do you observe around your school? What seems to be causing the collapse of values, if that is what you perceive? Or what keeps students on a moral and ethical journey?
Discuss conceptual merits and limitations of this hypothesis : Summarize Kuznets's Inverted-U Hypothesis and discuss the conceptual merits and limitations of this hypothesis, especially in reference to African countries.
Find out equilibrium price and output for market condition : Find out equilibrium price and output for the following market condition. Discuss a change in demand resulted in a change in the market price. Provide an example of how a change in supply resulted in a change in the market price. How does the price m..

Reviews

Write a Review

JAVA Programming Questions & Answers

  The goal is to create a project that would let a user

the goal is to create a project that would let a user compute area and perimeter of a polygon. restrict the type of

  How to read data in a link list

How to read data in a link list?

  Create a complete java application that meets these

create a complete java application that meets these requirements1. the program has an opening comments section using

  Sets a loop to find 10 random generated

Write a java code that 1) uploads a file 2) sets a loop to find 10 random generated words from the file and then search those words by a. IndexSequential Method b. indexBinary Method. then, report how much time both methods took.

  Java application to generate three-digit random number

Write a Java application that generates a 3-digit random number 100 times. Display the output for each of the generated numbers and the sum of all 100 numbers.

  Improve the efficiency of their operations

To help improve the efficiency of their operations, the Maitre De has hired you to write a program that simulates people waiting for tables. The goal is to determine the average amount of time people spend waiting for tables.

  Squashes the difference in fruit weight-distribution

Assume that in squashes the difference in fruit weight between a 3-lb type and a 6-lb type results from three independently segregating allelic pairs, A/a, B/b, and C/c. Each capital-letter allele contributes a half pound to the weight of the squash...

  Statement that catches and handles invalid data

Then, code a constructor that assigns default values to these variables. The default value you assign to the customer variable should prevent a NullPointerException - The parameters of this constructor should be given the same names as the instance..

  Write a program that creates an apartment object and prompts

Create a structure named Apartment that contains data fields to hold the number of bedrooms, the number of bathrooms, and the monthly rent for the apartment.

  Implement savings account using locks and conditions

A savings account object holds a non-negative balance - Use a shared counter protected by test-and-test-and-set lock. Each thread locks the counter, increments it, releases the lock, and repeatedly reads the counter until it reaches n.

  Write a program that plays a word game with the user

Write a program that plays a word game with the user. The program should ask the user to enter the following.

  Develop a java application for the local library

You have been requested to develop a Java application for the local library as part of an upgrade initiative. As in all libraries, this is a place where one can check out books

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd