Intro to programming Chapter 1-9 Questions Answers

Ace your homework & exams now with Quizwiz!

Which of the following println statements will display the last myScores element in an array of 10?

c. System.out.println(vals[9]);

When you ____methods, you risk creating an ambiguous situation—one in which the compiler cannot determine which method to use.

d. overload

A(n) ____ is simply a folder that provides a convenient grouping for classes.

d. package

Assigning ____ to a field means that no other classes can access the field's values.

d. private access

The ArrayList class ____ method removes an item from an ArrayList at a specified location.

d. remove

Languages such as Visual Basic, BASIC, and COBOL use ____ to refer to individual array elements.

a. ( )

____ refers to the order in which values are used with operators.

a. Associativity

After a successful compile, you can run the class file on any computer that has a ____.

a. Java language interpreter

A literal string is called a(n) ____.

a. anonymous object

Data items you use in a call to a method are called ____.

a. arguments

System.out.println("Your name is " + yourName); The above statement is an example of ____, which is used to join Strings.

a. concatenation

A(n) ____ dialog box typically displays the options Yes, No, and Cancel.

a. confirm

A(n) ____ method is a method that creates and initializes class objects.

a. constructor

A for loop provides a convenient way to create a(n) ____ loop.

a. counter-controlled

A ____ data type can hold 14 or 15 significant digits of accuracy.

a. double

The String class ____ method evaluates the contents of two String objects to determine if they are equivalent.

a. equals()

After an object has been instantiated, its methods can be accessed using the object's _____, a dot, and a method call.

a. identifier

Access specifiers are sometimes called access____.

a. modifiers

With ____ loops, the order of the conditional expressions can be important

a. nested

You are never required to use a switch structure; you can always achieve the same results with ____ statements.

a. nested if

A(n) ____ is a variable that holds a memory address.

a. reference

A(n) ____ causes a value to be sent from a called method back to the calling method

a. return statement

You may declare an unlimited number of variables in a statement as long as the variables are ____.

a. the same data type

The ____ is the type to which all operands in an expression are converted so that they are compatible with each other.

a. unifying type

The creators of Java chose ____ characters as the "extra" length for a StringBuilder object.

b. 16

int[][] myVals = {{2, 4, 6, 8}, {20, 40, 60, 80} }; Using the above two-dimensional array, what is the value of myVals[1][2]?

b. 60

You use a ____ following the closing brace of an array initialization list.

b. ;

____ parameters are variables in a method declaration that accept the values from the actual parameters.

b. Formal

What is the output of the following code: loopCount = 1; while(loopCount < 3) { System.out.println("Hello"); loopCount = loopCount + 1; }

b. Hello Hello

Which operator has the highest precedence?

b. NOT (!)

To declare a two-dimensional array in Java, you type two sets of ____ after the array type.

b. [ ]

Which escape sequence will move the cursor to the beginning of the current line?

b. \r

A(n) ____ is a type whose implementation is hidden and accessed through its public methods.

b. abstract data type

Methods that retrieve values are called ____ methods.

b. accessor

A literal string is a(n) ____ object.

b. anonymous

Both & and | are valid Java operators, but a single & or | with integer operands operates on individual ____ rather than making comparisons in logical conditions as && and || do.

b. bits

In a(n) ____, you repeatedly compare pairs of items, swapping them if they are out of order, eventually creating a sorted list.

b. bubble sort

A variable comes into existence, or ____, when you declare it.

b. comes into scope

You can use ____ arguments to initialize field values, but you can also use arguments for any other purpose.

b. constructor

A(n) ____ is a GUI object resembling a window in which you can place messages you want to display.

b. dialog box

A(n) ____ loop is one that performs no actions other than looping.

b. do-nothing

The ____ loop checks the value of the loop control variable at the bottom of the loop after one repetition has occurred.

b. do...while

A(n) ____ is a body with no statements in it.

b. empty body

Which of the following is NOT a component of a variable declaration statement?

b. ending colon

A(n) ____ is a kind of indefinite loop.

b. event-controlled

Public classes are accessible by all objects, which means that public classes can be ____, or used as a basis for any other class.

b. extended

The length ____ contains the number of elements in the array.

b. field

The Arrays class ____ method puts a particular value in each element of the array.

b. fill

A(n) ____ loop is a special loop that is used when a definite number of loop iterations is required.

b. for

Another name for a nonstatic member class is a(n) ____.

b. inner class

Every object is a _____ of a more general class.

b. member

If a class has only a default constructor, you must call the constructor using the keyword ____ for each declared array element.

b. new

When you declare an array name, no computer memory address is assigned to it. Instead, the array variable name has the special value ____, or Unicode value '\u0000'.

b. null

String oneStr = "Welcome Jim" String twoStr = "Welcome Joe" Given the lines of code above, which of the following regionMatches() expressions will result in a value of true?

b. oneStr.regionMatches(0, twoStr, 0, 7)

A(n) ____ block begins immediately after the method declaration and ends at the end of the method.

b. outer

Individual array elements are ____ by value when a copy of the value is made and used within the receiving method.

b. passed

A(n)____ operator compares two items and the result has a Boolean value.

b. relational

A ____ is an error not detected until the program asks the computer to do something wrong, or even illegal, while executing.

b. run-time error

It is a good programming practice to ensure that a subscript to an array does not fall below zero, causing a(n) ____.

b. runtime error

The compiler determines which version of a method to call by the method's ____.

b. signature

The ____ method and the startsWith() method each take a String argument and return true or false if a String object does or does not end or start with the specified argument, respectively.

b. strEnd()

A(n) ____ is an integer contained within square brackets that indicates one of an array's variables.

b. subscript

In a do...while loop, the loop will continue to execute until ____.

b. the loop control variable is false

Line comments start with ____.

b. two forward slashes

Which of the following describes a data type for which only appropriate behaviors are allowed?

b. type-safe

In programming, named computer memory locations are called ____because they hold values that might vary.

b. variables

Which of the following is NOT a valid method to increase a variable named score by 1?

c. ++score = score + 1

What is the output of the following code: for (loop = 1; loop <3; ++loop) System.out.print(1); for (loop2 = 1; loop2<3; ++loop2) System.out.print(2);

c. 122122

____ variables are variables that are shared by every instantiation of a class.

c. Class

____ occurs when both of the operands are integers.

c. Integer division

____ is a tool that helps programmers plan a program's logic by writing plain English statements.

c. Pseudocode

The arguments in a method call are often referred to as ____.

c. actual parameters

The AND operator is written as two ____.

c. ampersands

When you declare or access an array, you can use any expression to represent the size, as long as the expression is _____.

c. an integer

A Java variable's scope level is its ____.

c. block

Locating and repairing all syntax errors is part of the process of ____ a program.

c. debugging

When creating a for loop, which statement will correctly initialize more than one variable?

c. for(a=1, b=2)

A(n) ____ comparison is based on the integer Unicode values of the characters.

c. lexicographical

When an application is run, the method that must be executed first must be named ____.

c. main()

When you instantiate an object from a class, ____ is reserved for each instance field in the class.

c. memory

A(n) ____ is particularly useful when two conditions must be met before some action is taken

c. nested if statement

. If a class's only constructor requires an argument, you must provide an argument for every ____ of the class that you create.

c. object

When working with logical operators, you can always use ____ to change precedence.

c. parentheses

An instance variable or object field is also called a(n) ____ of the object

c. property

Normally, you declare constructors to be ____so that other classes can instantiate objects that belong to the class.

c. public

In Java, the reserved keyword ____ means that a method is accessible and usable even though no objects of the class exist.

c. static

It is a convenience to be able to use one reasonable name for ____ that are functionally identical except for argument types.

c. tasks

In a ____ environment, you can change directories using the cd command. For example, to change to a directory named MyClasses, you type cd MyClasses and press Enter

d. DOS

public class First { public static void main(String[] args) { System.out.println("First Java application"); } } Given the above code, which item identifies the name of the class?

d. First

The ____ is also called the Java class library; it contains information about how to use every prewritten Java class, including lists of all the methods you can use with the classes.

d. Java API

____ comments are a special case of block comments that are used to generate documentation.

d. Javadoc

Which line of code correctly creates a Scanner object?

d. Scanner inputDevice = new Scanner(System.in);

A ____ is a class for storing and manipulating changeable data that is composed of multiple characters.

d. StringBuilder

What is the output of the following code: loopCount = 1; while(loopCount < 3) System.out.println("Hello"); loopCount = loopCount + 1;

d. This is an infinite loop

The arguments in a method call are often referred to as ____ . The variables in the method declaration that accept the values from the actual parameters are ____.

d. actual parameters, formal parameters

You can initialize more than one variable in a for loop by placing a(n) ____ between the separate statements.

d. comma

When you place a block within an if statement, it is crucial to place the ____ correctly.

d. curly braces

In Java, you create an enumerated data type in a statement that uses the keyword ____.

d. enum

The simplest statement you can use to make a decision is the ____ statement

d. if

Methods used with object instantiations are called ____ methods

d. instance


Related study sets

NU272 PrepU Week 1 (Visual Impairment)

View Set

Rosetta Stone French Level 1 Unit 1 Lesson 1

View Set

week 10 carmen quiz: normal and binomial distributions

View Set

Chap. 39: Fluid, Electrolyte, and Acid-Base Balance

View Set

Inquizitive Chapter 22: Fighting for the Four Freedoms: World War II, 1941-1945

View Set