Java Cahpter 6,7

Ace your homework & exams now with Quizwiz!

________ refers to combining data and code into a single object.

Encapsulation

A constructor ________. has the same name as the class always has a private access specifier always accepts two arguments has the return type of void

Has the same name as the class

What does the following statement do? double[] array1 = new double[10]; It creates an instance of an array of ten double values. It will allow valid subscripts in the range of 0 through 9. It declares array1 to be a reference to an array of double values. It does all of these.

It does all of these.

Class objects normally have ________ that perform useful operations on their data, but primitive variables do not.

Methods

A group of related classes is called a(n) ________.

Package

A constructor is a method that ________.

Performs initialization or setup operations.

Instance methods do not have the ________ key word in their headers.

Static

Java allows you to create objects of the ________ class in the same way you would create primitive variables.

String

Which of the following statements will create a reference, str, to the String "Hello, World"?

String str = "Hello, World";

The scope of a public instance field is ________.

The instance methods and methods outside the class

The sequential search algorithm ________.

Uses a loop to sequentially step through an array, starting with the first element

What does the following UML diagram entry mean? + setHeight(h : double) : void

a public method with a parameter of data type double that does not return a value

For the following code, what would be the value of str[2]? String[] str = {"abc", "def", "ghi", "jkl"};

a reference to the String object containing "ghi"

A ragged array is ________.

a two-dimensional array where the rows are of different lengths

The ________ method is used to insert an item into an ArrayList.

add

The following statement is an example of ________.import java.util.Scanner;

an explicit import statement

Java performs ________, which means that it does not allow a statement to use a subscript that is outside the range of valid subscripts for the array.

array bounds checking

A(n) ________ can be thought of as a blueprint that can be used to create a type of ________.

class, Object

In memory, an array of String objects ________.

consists of an array of references to String objects

Overloading means that multiple methods in the same class ________.

have the same name but different parameter lists

You should not define a class that is dependent on the values of other class fields ________.

in order to avoid having stale data

Another term for an object of a class is a(n) ________.

instance

Which of the following is a valid declaration for a ragged array with five rows but no columns?

int[][] ragged = new int[5][];

A search algorithm ________.

is used to locate a specific item in a larger collection of data.

When an array is passed to a method ________.

it is passed just as any other object would be passed the method has direct access to the original array a reference to the array is passed All of these are true

The ________ package is automatically imported into all Java programs.

java.lang

Each array in Java has a public field named ________ that contains the number of elements in the array.

length

To return an array of long values from a method, which return type should be used for the method?

long[]

A reference variable stores a(n) ________.

memory address

If numbers is a two-dimensional array, which of the following would give the number of columns in row r?

numbers[r].length

A UML diagram does not contain ________.

object names

Which of the following is a correct method header for receiving a two-dimensional array as an argument?

public static void passMyArray(int[][])

The ________ method removes an item from an ArrayList at a specific index.

remove

In order to do a binary search on an array ________.

the array must first be sorted

The scope of a private instance field is ________.

the instance methods of the same class

The binary search algorithm ________.

will cut the portion of the array being searched in half each time it fails to locate the search value

LOOK AT THE CODE IN HW 6,7

!

Data hiding (which means that critical data stored inside the object is protected from code outside the object) is accomplished in Java by ________.

using the private access specifier on the class fields

Which symbol indicates that a member is public in a UML diagram?

+

Given the following two-dimensional array declaration, which statement is true?int[][] numbers = new int[6][9];

The numbers array has 6 rows and 9 columns.

Which symbol indicates that a member is private a UML diagram?

-

If final int SIZE = 15 and int[] x = new int[SIZE], what would be the range of subscript values that could be used with x[]?

0 through 14

It is common practice in object-oriented programming to make all of a class's ________.

fields private

Given that String[] str has been initialized, to get a copy of str[0] with all the characters converted to uppercase, you would use the ________ statement.

str[0].toUpperCase();

When an individual element of an array is passed to a method ________.

the method does not have access to the original array

When an object is passed as an argument to a method, what is passed into the method's parameter variable?

the object's memory address

Two or more methods in a class may have the same name as long as ________.

they have different parameter lists


Related study sets

Human Growth and Development Unit 7 Review

View Set

NUR1460 Fundamentals HESI Attempt 2 Study Guide

View Set

Sling Load Inspector Certification Course

View Set

MGMT 490: Exam 1 - Learnsmart, Activity and Quiz Questions

View Set