JAVA I Exam 4

Ace your homework & exams now with Quizwiz!

buffer

A StringBuilder object, however, contains a memory block called a ____, which might or might not contain a string. The actual length of the ____ is the capacity of the StringBuilder object and it might not be occupied fully.

final

A ___ class cannot be a parent.

base class

A class that is used as a basis for inheritance is a _____.

anonymous object

A literal string is an unnamed object, or ____, of the String class

case

A second version of the regionMatches() method takes an additional boolean argument as the first argument. This argument represents whether ____ should be ignored in deciding whether regions match. ex. thirdString.regionMatches(true, 4, fourthString, 2, 5)

nonprivate

Although a child class cannot inherit its parent's static methods, it can access its parent's _____ static methods the same way any other class can.

inlining

Because a final method's definition can never change—that is, can never be overridden with a modified version—the compiler can optimize a program's performance by removing the calls to final methods and replacing them with the expanded code of their definitions at each method call location. This process is called ____ the code.

polymorphism

Because the toString() method you use with println() takes arguments of any primitive type, including int, char, double, and so on, it is a working example of ____.

String argument

Because you see a String used between the parentheses in the method call, you can tell that the equals() method takes a ____. ex. public boolean equals(String s)

Float, Long

Besides Double and Integer, other wrapper classes such as ____ and ____ also provide methods such as parseFloat() and parseLong().

data type, minus, plus

By convention, a class diagram contains the ____ following each attribute or method. A ____ sign is inserted in front of each private field or method, and a ___ sign is inserted in front of each public field or method.

polymorphism

If a programming language does not support ____, the language is not considered object oriented.

descendant, original

In a UML diagram, an inheritance relationship is indicated with an arrow that points from the ____ class to the _____ class.

new, class

Java provides a shortcut, so you can declare a String containing "Hello" with the following statement that omits the keyword ______ and does not explicitly call the ____ constructor:

four

One version of the regionMatches() method takes ____ arguments—the position at which to start in the calling String, the other String being compared, the position to start in the other String, and the length of the comparison. ex. firstString.regionMatches(1, secondString, 2, 4)

upcast

Programmers say that instanceof yields true if the operand on the left can be ____ to the operand on the right.

immutable

Strings and other objects that can't be changed are ____.

lexicographical, Unicode

Technically, the equals() method does not perform an alphabetical comparison with Strings; it performs a ____ comparison—a comparison based on the integer ____ values of the characters.

wrapper

The Integer class is an example of a ____. A _____ is a class or object that is "wrapped around" a simpler element (ex. int anInt = Integer.parseInt("649");)

equals()

The String class ________ method evaluates the contents of two String objects to determine if they are equivalent. The method returns true if the objects have identical contents, no matter how the contents were assigned. For

Character

The ____ class is defined in java.lang and is automatically imported into every program you write. The ____ class inherits from java.lang.

replace()

The ____ method allows you to replace all occurrences of some character within a String.

regionMatches()

The ____ method can be used to test whether two String regions are the same.

length()

The ____ method is an accessor method that returns the length of a String.

insert()

The ____ method lets you add characters at a specific location within a StringBuilder object. ex. phrase.insert(6, "30th ");

reusable

The concept of inheritance is useful because it makes a class's code more easily ____.

super

The keyword ____ always refers to the superclass of the class in which you use it.

Boolean, character

The methods that begin with "is", such as isUpperCase(), return a ____ value that can be used in comparison statements; the methods that begin with "to", such as toUpperCase(), return a ____ that has been converted to the stated format.

case sensitive

The replace() method is ____.

static methods final methods Methods within final classes

The three types of methods that you cannot override in a subclass are:

Object

The toString() method originates in the ___ class

override

To ______ a field or method in a child class means to use the child's version instead of the parent's version.

setCharAt()

To alter just one character in a StringBuilder object, you can use the ____ method, which allows you to change a character at a specified position. This method requires two arguments: an integer position and a character. ex. phrase.setCharAt(6, '4');

wrapper

To convert a String object to a double value, you must use the Double class, which, like the Integer class, is a ____ class and is imported into your programs automatically. (ex. double doubleValue = Double.parseDouble("147.82");)

subtype polymorphism

When Java developers refer to methods that work appropriately for subclasses of the same parent class, the more specific term is ____.

superclass, subclass

When constructors initialize variables, you usually want the ____ constructor to take care of initializing the data fields that originate in the superclass. Usually, the ____ constructor only needs to initialize the data fields that are specific to the subclass.

constructor

When you create any object, you are calling a ____

superclass, subclass

When you instantiate an object that is a member of a subclass, you are actually calling at least two constructors: the constructor for the base class and the constructor for the extended, derived class. When you create any subclass object, the ____ constructor must execute first, and then the ___ constructor executes.

compareTo()

When you use ________ to compare two String objects, the method: - returns zero if the values of two Strings are exactly the same. - returns a negative number if the calling object is "less than" the argument. - returns a positive number if the calling object is "more than" the argument

arguments

When you use a class as a superclass and the class has only constructors that require ___, you must be certain that any subclasses provide the superclass constructor with the___ it needs. ex. super(list of arguments);

16

Whenever you create a StringBuilder object using a String as an argument to the constructor, the StringBuilder's capacity is the length of the String contained as the argument to the StringBuilder, plus ___.

public, private

Without the _____ get and set methods, there would be no way to access the ___ data fields.

instanceof

You can use the ____ operator to determine whether an object is a member or descendant of a class.

first

You cannot use both this() and super() in the same constructor because each is required to be the ____ statement in any constructor in which it appears.

java.lang

You don't need import statements to use toString() because it is part of ____, which is imported automatically.

directly

You only need to make parent class fields protected if you want child classes to be able to access parent data ____, but you still want to prohibit other classes from accessing the fields.

extends

You use the keyword ____ to achieve inheritance in Java

size

You usually can distinguish superclasses from their subclasses by ____.

Inheritance

____ is a mechanism that enables one class to acquire all the behaviors and attributes of another class

Protected access

____ provides you with an intermediate level of security between public and private access.

reference

a variable that holds a memory address

StringBuilder and StringBuffer

classes for storing and manipulating changeable data composed of multiple characters


Related study sets

EMT Chapter 33 - Obstetrics and Neonatal Care

View Set

Government unit 4: The Executive Branch

View Set

Chapter 6. Cost-Volume-Profit Relationships

View Set

5. AZ ÁLLAM MINT GAZDASÁGI SZEREPLŐ, AZ EGYÉN ÉS AZ ÁLLAM GAZDASÁGI KAPCSOLATAI

View Set

Area and Circumference of Circles

View Set

Chapter 5: Provisions, Options & Riders

View Set

AP Gov Unit 3, Lesson 1 (16) - Understanding the Judiciary

View Set