Determine the number of elements in the array

Assignment Help JAVA Programming
Reference no: EM131602688

Question 1
When using an array, what can be used to determine the number of elements in the array?

use the array's length() method

use the array's length property

use the array's size() method

use the array's size property

Question 2
Overriding is when you:

define a class using the same class name but a different number of parameters

define two classes using the same name but different constructors

define a method in a subclass and superclass with the same name.

define two methods with the same name but different number of parameters

Question 3
To access an element in an Array object,

use the array's index value.

use the element() method.

use the get() method.

use the position property.

Question 4
To access an element in an ArrayList object,

use the array's index value.

use the element() method.

use the get() method.

use the position property.

Question 5
Which GUI component would be used to allow text to be entered?

a JTextField

a JTextBox

a JTextFrame

a JTextLabel


Question 6
Which method call would change the window title to "Hello"?

setTitle("Hello")

setWindowTitle("Hello")

setFrame("Hello")

setFrameTitle("Hello"

Question 7
When a button-click event occurs, which item below must be implemented?

ActionEvent interface

ActionPerformed interface

AactionListener interface

WindowListener interface

Question 8
Which method should be used to determine which component caused the fired event?

getInstance()

getSource()

getEvent()

getActionCommand()

Question 9
Which layout manager causes components to be positioned in the top-center position?

BorderLayout

FlowLayout

GridBagLayout

GridLayout

GridlessLayout

Question 10
Which two methods come from the Component class which is an ancestor of the JFrame class?

setTitle()

setDefaultCloseOperation()

setLayout()

setVisible()

Question 11
Which is the proper way to enable Line Wrap on a JTextArea?

setLineWrap(1);

setLineWrap(word);

setLineWrap(true);

setLineWrap(on);

True/False questions: circle the best answer.

Question 12
When using Short-circuit evaluation, if the left side of an "and" operation is false, the right side is not evaluated.

True

False

Question 13
The following is an example of a "Ternary" operator.
(a > b) ? x : y

True

False

Question 14
A "catch" block can only check one exception at a time. Subsequent catch blocks are needed for each additional exception.

True

False

Question 15
Use of the access modifier public provides for better encapsulation and ensures access is possible for any class needed direct access to the variable in question.

True

False

Question 16
When using parseInt() to convert a String to a number, a non-integer value causes a runtime error.

True

False

Question 17
The getSource method is used to determine the component causing the event that was fired from inside an actionPerformed method.

True

False

Question 18
Write the statement to access the 8th element of the array defined below?
Integer [] priceList = new Integer [10];
HTML EditorKeyboard Shortcuts

Font Sizes
Paragraph

Question 19
Add the variable called input to the ArrayList declared below.
private static ArrayList<Integer> floors = new ArrayList<>();
HTML EditorKeyboard Shortcuts

Font Sizes
Paragraph
p

Question 20
Given the code below, a syntax error prevents it from compiling and running.

Which line is causing the syntax error?
HTML EditorKeyboard Shortcuts

Font Sizes
Paragraph

Question 21
Given the code below, a syntax error prevents it from compiling and running.
What is the output?

Which line is causing the syntax error?
HTML EditorKeyboard Shortcuts

Font Sizes
Paragraph

Question 22
Assume this program compiles and runs.
Assume that the user enters 1 2 3 4(separated by spaces) for input.
What is the output?

1 2 3 4

4 3 2 1

3 4 1 2

2 1 4 3

Question 23
Given the following code fragment, what is the output?

0

6

Division by zero

Other Exception

Question 24
Assume 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.


0

6

Other Exception

Division by zero

Question 25
Assume these 3 classes compile and run.
What is the output?


Robert in Driver

Robert in Person

Robert in Student

Neither of the above

Question 26
Assume these 3 classes compile and run.
What is the output?


Robert

Robert in Driver

Robert in Student

Robert in Person

Question 27
- Create a driver program that creates an instance of a dog class using the default constructor.
- Call a method called setName to set the name of your dog to "Max".
- Implement the dog class to include a default constructor and a setName method.
- Include any instance variables needed.
- Provide comments as necessary.

HTML EditorKeyboard Shortcuts

Font Sizes
Paragraph

Question 28
Provide the code for a class called Grades.java that would work with the driver class provided below.

import java.util.Random;
public class Driver
{
public static void main(String [] args)
{
Grades [] studentGrades = new Grades[25];
for (int x=0; x<studentGrades.length; x++)
studentGrades[x] = new Grades();
Random rand = new Random();
for (int x=0; x<studentGrades.length; x++)
{
int grade = rand.nextInt(51)+50;
studentGrades[x].addEntry(grade);
}
Grades.showResults(studentGrades) ;
}
}
When the program runs, the following random output should be produced: (numbers will vary due to random)

Lowest Grade: 60
Highest Grade: 99
Average: 78

Program specific requirements for Grades class:
- Declare 3 static variables for lowest, highest, and average grades. 
- Declare 1 instance variable to hold the grade. 
- addEntry Method
o provide a proper header which receives grade as input 
o store received grade in instance variable 
- showResults Method
o provide a proper class method header which receives array 
o utilize a for loop to iterate through array 
o add up grades into total static variable 
o set low to lowest grade received 
o set high to highest grade received 
o output lowest grade 
o output highest grade 
o output average grade 

Reference no: EM131602688

Questions Cloud

Punishment by prevention of reinforcer : Decide which of the following concepts are most applicable to each scenario: differential reinforcement of other behavior, avoidance contingency.
Find the equation of the best quadratic approximation : Find the equation of the best quadratic approximation to y = ln x at x = 1. The best quadratic approximation has the same first and second derivatives.
General level of wages in the united states : Explain why the general level of wages in the United States and other developed nations is high.
Factor that is associated with lower-producing employees : Select one factor that is associated with productive employees and one factor that is associated with lower-producing employees.
Determine the number of elements in the array : what can be used to determine the number of elements in the array - define a class using the same class name but a different number of parameters
What are the coordinates of the point of tangency : If k = 1, the graphs of y = sin x and y = ke-x intersect for x = 0. Find the smallest value of k for which the graphs are tangent.
Us exporting industries affected : With the tariffs imposed, how is the level of exports in other U.S. exporting industries affected? Explain Answers.
What factors may make members other groups : What factors may make members of this group more or less likely to attempt suicide than members of other groups
Find the equations of the tangent lines to the graph : Find the equations of the tangent lines to the graph of f(x) = sin x at x = 0 and at x = p/3. Use each tangent line to approximate sin(p/6).

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a program that will take representing exam scores

Write a program that will take 10 values representing exam scores (0-100) for a student. Then display a menu - error check all entries (menu selections and

  Update your website to include a simple web form

Update your website to include a simple web form as discussed in your design document. Use JavaScript to validate the form contents and display the results of that validation to the user in a popup window

  Create a class of students in a college

Create a class of students in a college. Make sure you include the following instance/member variables - Create a non-default constructor

  Calculate the optimal position of the large pipeline

Your task is to calculate the optimal position (on the y-axis) of the large pipeline, so that the total length of all smaller pipelines is shortest

  Prompts the user to enter 4 numbers for a salesperson

Write a program (SalespersonCommission.java) that prompts the user to enter 4 numbers for a salesperson's items sold for last week and displays that salesperson's earnings.

  Implement a training system for company directors

Object Oriented Software Engineering (COMP2003) - You have been asked to design and implement a training system for company directors. In the best tradition of economics, we shall start by making things up.

  Declare an array of cube objects

What change should you make to the above class to ensure data encapsulation is followed and users can create

  Write a program in java for searching of an item

Write a program in java for searching of an item in a list of n numbers using linear search.

  Write an application that accepts a users password

Write an application that accepts a user's password from the keyboard. When the entered password has fewer than six characters, more than 10 characters, or does not contain at least one letter and one digit.

  Website that utilizes drag-and-drop or web sockets

A website that utilizes drag-and-drop or web sockets. Review the website source, and evaluate how the author created the pages

  Write a program to read five integers and print their sum

Write a program in Java to read 5 integers and print their sum and average. Use loop statements in your code. What is value of m after running the given code?

  Write a recursive method to reverse a string.

write a recursive method to reverse a string. Explain why you would not normally use recursion to solve this problem?

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