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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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