Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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 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[x] = new Grades();
Random rand = new Random();
for (int x=0; 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 

Java, Programming

  • Category:- Java
  • Reference No.:- M92411401
  • Price:- $20

Priced at Now at $20, Verified Solution

Have any Question?


Related Questions in Java

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As