Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( 2 pts ) In an array declaration, this indicated the number of elements that the array will have. subscript size declarator element sum reference

(2 pts) In an array declaration, this indicated the number of elements that the array will have.
subscript
size declarator
element sum
reference variable
2.
(2 pts) The last subscript in an array is always ________________
100
0
-1
1 less than the number of elements
3.
(2 pts) This array field holds the number of elements that the array has
size
elements
length
width
4.
(2 pts) This type of method cannot access any non-static member variables in its own class.
instance
void
static
non-static
5.
(2 pts) Making an instance of one class a field in another class is called _______.
nesting
class fielding
aggregation
concatenation
2
6.
(2 pts)) If you write this method for a class, Java will automatically call it any time you concatenate an object of the class with a string
toString
plusString
stringConvert
concatString
7.
(2 ptsThe String class has several overloaded versions of a method that accepts a value of any primitive data type as its argument and returns a string representation of the value. The name of the method is __________________
stringValue
valueOf
getString
valToString
8.
(2 pts) To change the value of a specific character in a StringBuilder object, use this method.
changeCharAt
setCharAt
setChar
change
9.
(2 pts) The character that separated tokens in a string is known as a ____________
separator
tokenizer
delimiter
Terminator
10.
(2 pts) This String method breaks a string into tokens.
break
tokenize
getTokens
split
9
Part 2(80 pts)
1.
Write a statement that declares an integer array named test. Initialize the array with the following values: 20,71,-9,10,56(4 points)
2.
Write a loop (while or for) that displays the contents of a double array (named temp). Assume that the array was created and initialize with values. (6 points)
9
3.
Write a method that accepts an integer array as an argument and returns the sum of the values of the array plus 4(15 points)
9
4.
Given the following code, what is the output(6 points)
import java.util.ArrayList;
public class Pg4{
public static void main(String[] args)
{
ArrayList pets = new ArrayList();
pets.add("Duncan");pets.add("Miles");for (int i =0; i < pets.size(); i++){ System.out.println(pets.get(i));}System.out.println(pets.get(1));
}
Output:
9
5.
Write a method (just the method) called checkDigit that accepts a String as its argument. The method should return true if the string contains a digit, otherwise, it should return false. (15 points)
9
6.
Write a loop that counts the number of lowercase characters that appear in the String object str.(10 points).
7. What would be the output if you call this method with the argument 2,4,6,11 in a println statement from the main method? (8 points)
public static int testString(String str){ int count =0; String[] s = str.split(","); for (int i =0; i < s.length; i++){ if (Integer.parseInt(s[i])>10){ count++; System.out.println("Below 20"); }} return count;
Answer : ______________________________
9
8.
EXTRA CREDIT (18 POINTS)
Write a Java program (complete program with main) with the following properties:
Has a 2-dimensional integer array with 3 rows and 3 columns (2 points)
Assign any values to the elements in the array (4 points)
Find the largest value in the array (5 points)
Find the smallest value in the array (5 points)
Output the largest value and the smallest value to the screen (2 points)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions