Java Exam 2

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

primitive variable

When you are working with a ________, you are using a storage location that holds a piece of data. reference variable primitive variable binary number numeric literal

All of these

Which of the following are classes from the Java API? Scanner Random PrintWriter All of these

initialization list

In Java, you do not use the new operator when you use a(n): array size declarator initialization list two-dimensional array All of these

class; objects

In the cookie cutter metaphor, think of the ________ as a cookie cutter and ________ as the cookies. class; fields class; objects attribute; methods object; classes

True

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

False

Instance methods should be declared static.

array bounds checking

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 active array sequencing buffer overrun protection scope resolution binding

class

One or more objects may be created from a(n): field class instance method

have the same name, but different parameter lists

Overloading means multiple methods in the same class: have the same name, but different return types have different names, but the same parameter list have the same name, but different parameter lists perform the same function

import

Quite often you have to use this statement to make a group of classes available to a program. use assume link import

0

Subscript numbering always starts at what value? 0 1 -1 None of these

performs initialization or setup operations.

A constructor is a method that: never receives any arguments. returns an object of the class. performs initialization or setup operations. with the name ClassName.constructor.

True

A method that stores a value in a class's field or in some other way changes the value of a field is known as a mutator method.

Encapsulation

This refers to the combining of data and code into a single object. Object Data hiding Encapsulation Abstraction

A memory address

What is stored by a reference variable? A binary encoded decimal A memory address A string An object

subscript

What do you call the number that is used as an index to pinpoint a specific element within an array? element subscript argument global unique identifier

String str = "Hello, World";

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

1 and 2

Which of the following statements will create a reference, str, to the string, "Hello, world"? (1) String str = new String("Hello, World"); (2) String str = "Hello, World"; 1 2 1 and 2 neither 1 or 2

in order to avoid having stale data

You should not define a class field that is dependent upon the values of other class fields: because it should be defined in another class in order to avoid having stale data because it is redundant in order to keep it current

True

An ArrayList object automatically expands in size to accommodate the items stored in it.

False

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

It specifies that only String objects may be stored in the ArrayList object

The following statement creates an ArrayList object. What is the purpose of the <String> notation? ArrayList<String> arr = new ArrayList<String>(); It specifies that String objects may not be stored in the ArrayList object. It specifies that the get method will return only String objects. It specifies that only String objects may be stored in the ArrayList object. It specifies that everything stored in the ArrayList object will be converted to a String.

the instance methods and methods outside the class

The scope of a public instance field is: inside the parentheses of a method header the instance methods and methods outside the class only the class in which it is defined inside the class, but not inside any method


Kaugnay na mga set ng pag-aaral

life insurance questions for exam

View Set

CS 115: Computers and Applications

View Set

Chapter 16: Auditing Operations & Completing the Audit

View Set

Chapter 2 Assessment: Sociological Research

View Set

Psychology Chapter 16, Psychology - Chapters 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16

View Set