exam 2

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

________ is the term for the relationship created by object aggregation.

"Has a"

The whole-part relationship created by object aggregation is more often called a(n) ________ relationship

"has a"

In the method header the static method modifier means the method is available to code outside the class.

False

The key word this is the name of a reference variable that is available to all static methods.

False

The term "default constructor" is applied to the first constructor written by the author of the class

False

If you write a toString method for a class, Java will automatically call the method any time you concatenate an object of the class with a string.

True

You must have a return statement in a value-returning method

True

If the this variable is used to call a constructor, ________.

a compiler error will result if it is not the first statement of the constructor

When a method's return type is a class, what is actually returned to the calling program?

a reference to an object of that class

An object's ________ is simply the data that is stored in the object's fields at any given moment.

state

To compare two objects in a class, ________.

write an equals method that will make a field by field compare of the two objects

Declaring an array reference variable does not create an array.

True

Java does not limit the number of dimensions an array may have.

True

Methods are commonly used to break a problem into small manageable pieces.

True

The String[] args parameter in the main method header allows the program to receive arguments from the operating system command-line.

True

The term "no-arg constructor" is applied to any constructor that does not accept arguments.

True

When an array of objects is declared but not initialized, the array values are set to null.

True

When an object is passed as an argument, it is actually a reference to the object that is passed.

True

enum constants have a toString method.

True

You cannot use the fully-qualified name of an enum constant for ________.

a case expression

In the following code, System.out.println(num) is an example of ________. double num = 5.4; System.out.println(num); num = 0.0;

a void method

Values that are sent into a method are called ________.

arguments

The ________ indicates the number of elements the array can hold

array's size declarator

Java automatically stores a ________ value in all uninitialized static member variables.

0

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

The following statement is an example of ______ import java.util.*;

A wildcard import

What would be the result of executing the following code? int[] x = {0, 1, 2, 3, 4, 5};

An array of 6 values, ranging from 0 through 5 and referenced by the variable x will be created.

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

An explicit import

One or more objects may be created from a(n) ________.

Class

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

False

An array can hold multiple values of several different types of data simultaneously.

False

If a[] and b[] are two integer arrays, the expression a == b compares the array contents.

False

Methods that operate on an object's fields are called ________.

Instance methods

Select all that apply. Which of the following statements is(are) true about this code? final int ARRAY_SIZE = 10; long[] array1 = new long[ARRAY_SIZE];

It creates an instance of an array of ten long values. It will allow valid subscripts in the range of 0 through 9. It declares array1 to be a reference to an array of long values.

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

Package

A constructor is a method that ________.

Performs initialization or setup operations.

When you work with a ________, you are using a storage location that holds a piece of data.

Primitive variable

Methods are commonly used to ________.

break a program down into small manageable pieces

To create a method, you must write its _______

definition

In a @return tag statement the description ________.

describes the return value

The JVM periodically performs the ________ process to remove unreferenced objects from memory

garbage collection

When an argument is passed to a method ________.

its value is copied into the method's parameter variable

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

numbers[r].length

In the header, the method name is always followed by ________.

parentheses

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

public static void passArray(int [][])

Which of the following is not a part of a method call?

return type

A parameter variable's scope is ________.

the method in which the parameter is declared

If you attempt to perform an operation with a null reference variable ________.

the program will terminate

A partially filled array is normally used ________.

with an accompanying integer value that holds the number of items stored in the array

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

+

When a local variable in an instance method has the same name as an instance field, the instance field hides the local variable.

False

You can declare an enumerated data type inside a method.

False

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

Fields private

Which of the following is not true about static methods?

They are called from an instance of the class.

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

They have different parameter lists

A value-returning method can return a reference to a non-primitive type.

True

Any items typed on the command line, separated by a space, after the name of the class are considered to be one or more arguments that are to be passed into the main method.

True

Constants, variables, and the values of expressions may be passed as arguments to a method

True

When an object, such as a String, is passed as an argument it is ________.

actually a reference to the object that is passed

In Java, you do not use the new operator when you use a(n) ________.

initialization list

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

long[]

Enumerated types have the ________ method which returns the position of an enum constant in the declaration list.

ordinal

Given the following method, which of these method calls is valid? public static void showProduct (double num1, int num2) { double product; product = num1 * num2; System.out.println("The product is " + product); }

showProduct(3.3, 55);

Given the following method header, what will be returned from the method? public Rectangle getRectangle()

the address of an object of the Rectangle class

When you pass an argument to a method you should be sure that the argument's type is compatible with ________.

the parameter variable's data type

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

true

A ________ type of method performs a task and then terminates.

void

What would be the result after the following code is executed? int[] x = {23, 55, 83, 19}; int[] y = {36, 78, 12, 24}; x = y; y = x;

x[] = {36, 78, 12, 24} and y[] = {36, 78, 12, 24}

Both instance fields and instance methods are associated with a specific instance of a class, and they cannot be used until an instance of the class is created

True

In a general sense, a method is ________.

a collection of statements that perform a specific task

A constructor ________.

Has the same name as the class

Overloading means that multiple methods in the same class ________.

Have the same name, but different parameter lists

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

Static

Which of the following for loops is valid, given the following declaration? String[] names = {"abc", "def", "ghi", "jkl"}; for (int i = 0; i < names.length(); i++)

System.out.println(names[i].length()); for (int i = 0; i < names.length; i++)

The scope of a private instance field is ________.

The instance methods of the same class

If the following is from the method section of a UML diagram, which of the statements below is true? + equals(object2:Stock) : boolean

This is a public method that accepts a Stock object as its argument and returns a boolean value.

A class's responsibilities include ________.

The things a class is responsible for doing & for knowing (Both

What would be the result after the following code is executed? int[] numbers = {50, 10, 15, 20, 25, 100, 30}; int value = 0; for (int i = 1; i < numbers.length; i++) value += numbers[i];

The value variable will contain the sum of all the values in the numbers array.

To indicate the data type of a variable in a UML diagram, you enter ________.

The variable name followed by a colon and the data typ

A method ________.

may have zero or more parameters


संबंधित स्टडी सेट्स

VCU MGMT 310 - Chapter 18 Assignment

View Set

BL Linux - Ch. 18 - Logging and Time Services

View Set

Management & Leadership - Module CH. 13

View Set

Chapter 4 - Folk and Popular Culture

View Set

Science Chapter 4 Section 1 Earth's Atmosphere

View Set