• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/60

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

60 Cards in this Set

  • Front
  • Back

The identifier of the object is called the _____.

object reference

Creating an object of a class is called _____, and the object is called an _____

instantiating an object


instance of the class.

The data associated with an object of a class are called _____, or _____.

instance variables


fields

The operations for a class is called _____.

methods

Invoking a method on an object is called _____.

calling the method

The fields and methods of a class are called its _____.

members

We say that the data is private to the class. In other words, the class _____ the data and the methods provide the only interface for setting or changing the data values.

encapsulates

How to instantiate objects and how to call the class methods

Application Programming Interface (API)

A special method of the class.


The job of the _____ is to assign initial values to the data of the class.

Constructor

Class code is already written and tested
New applications can be built faster
The applications will be more reliable


These explains _____.


Reusability

The _____ consists of a comma-separated list of initial data values to assign to the object.

argument list

_____'s argument is empty. This constructor assigns default values to all data in the object.

Default constructor

_____ is so-called "get " methods and return the current values of object data.

Accessor methods

_____ is so-called "set" methods and change the values of object data.

Mutator methods

The _____ is used in an expression. When the expression is evaluated, this replaces the method call.

method returns a value

Declare a variable named myMenu suitable for holding references to Menu Objects.

Menu myMenu;

Declare a reference variable of type File named myFile.

File myFile

Suppose a reference variable of type String called myString has already been declared. Create an object of type String and assign it to the reference variable myString.

String myString2 = new String();


myString = myString2;

Suppose a reference variable of type File called myFile has already been declared. Create an object of type File with the initial file name input.dat and assign it to the reference variable myFile.

myFile = new File("input.dat");

Suppose a reference variable of type Double called myDouble has already been declared. There is also a double variable x that has been declared an initialized. Create and object of type Double with the initial value of x and assign it to the refence variable myDouble.

Double myDouble2 = new Double(x);


myDouble = myDouble2;

One of the constructors for PrintStream class has a single OutputStream argument. Assume that dos is a variable that references an OutputStream object. Create a PrintStream object using dos and assign the resulting reference to ps, a PrintStream variable that has already been declared.

ps = new PrintStream(dos);

Assume that arithmetic is a reference to an object that has a method named add, that accepts two int arguments and returns their sum. Two int variables, euroSales and asiaSales have already been declared and initialized. Another int variable, eurasiaSales, has already been declared. Write a statement that calls add to compute the sum of euroSales and asiaSales and that stores this value in eurasiaSales.

eurasiaSales = arithmetic.add(euroSales, asiaSales);

Assume that dateManager is a reference to an object that has a method named printTodaysDate, that accepts no arguments and returns no value. Write a statement that calls printTodaysDate.

dateManager.printTodaysDate();

Assume that dataTransmitter is a variable that refers to an object that provides a method, named sendObject. There is one argument for this method, a reference to a Customer object. Assume that there is a reference to an object of type Customer, in a variable called john_doe. Invoke the method, using this reference as your argument.

dataTransmitter.sendObject(john_doe);

21141: Assume that dataTransmitter is a variable that refers to an object that provides a method, named sendNumber. There is one int arugment for this method. Invoke this method and use the number 5 as an argument.

dataTransmitter.sendNumber(5);

21145: Assume that dataTransmitter is a variable that refers to an object that provides a method , named sendTwo . There are two arguments for this method : a double and an int . Invoke the method with the double value of 15.955 and the int valueof 133 .

dataTransmitter.sendTwo(15.955, 133);

Assume there is a class AirConditioner that supports the following behaviors : turning the air conditioner on and off. The following methods are provide this behavior : turnOn and turnOff . Both methods take no arguments and return no value .
Assume there is a reference variable myAC to an object of this class , which has already been created. Using the reference variable , invoke a method to tell the air conditioner object to turn on.

myAC.turnOn();

20817: Assume that the String variable named text has already been declared. Assign to it the empty string.

text = "";

20950: Declare a String variable named oneSpace, and initizlie it to a String consisting of a single space.

String oneSpace = new String (" ");

20815: Write the declaration of two String variables named background and selectionColor and initialize them to “white” and “blue” respectively.

String background = new String ("white");
String selectionColor = new String ("blue");

20820: Given a String variable address , write a String expression consisting of the string "http://" concatenated with the variable 's String value . So, if the variable refers to "www.turingscraft.com", the value of the expression would be "http://www.turingscraft.com".

"http://" + address

20963: Given a String variable word, write a String expression that parenthesizes the value of word. So, if word contains “sadly”, the value of the expression would be the String “(sadly)”

"(" + word + ")"

20850: Given four int variables that have been declared and given values, octet1, octet2, octet3, and octet4, write a String expression whose value is the String equivalent of each of these variables joined by a single period(.)

octet1 + "." + octet2 + "." + octet3 + "." + octet4

20819: Given a String variable named sentence that has been initialized , write an expression whose value is the number of characters in the String referred to by sentence.

sentence.length()

20818: Write an expression whose value is the number of characters in the following String: "CRAZY!\n\\\t\\\\\\\\\\n. . . .\\\\\r\007'\\'\"TOOMUCH!"

"CRAZY!\n\\\t\\\\\\\\\\n. . . .\\ \\\r\007'\\'\"TOOMUCH!".length()

20810: Given the String variable str, write an expression that evaluates to the character at index 0 of str.

str.charAt(0)

20822: Assume that name is a variable of type String that has been assigned a value. Write an expression whose value is the first character of the value of name. So if the value of name were “Smith” the expression’s value would be ‘S’.

name.charAt(0)

20811: Given the String variable name, write an expression that evaluates to the third character of name.

name.charAt(2)

20871: Given a String variable named sentence that has been initialized, write an expression whose value is the index of the very last character in the String referred to by sentence.

sentence.length() - 1

20952: Assume that name is a variable of type String that has been assigned a value. Write an expression whose value is the last character of the value of name. So if the value of name were “Blair” the expression’s value would be ‘r’.

name.charAt(name.length() - 1)

20876: Assume that word is a variable of type String that has been assigned a value. Write an expression whose value is a String consisting of the first three characters of the value of word.

word.substring(0,3)

20878: Assume that name is a variable of type String that has been assigned a value. Write an expression whose value is a String containing the second character of the value of name.

name.substring(1,2)

20879: Write an expression that results in a String consisting of the third through tenth characters of the String s.

s.substring(2,10)

20880: Assume that name is a variable of type String that has been assigned a value. Write an expression whose value is a String containing the last character of the value of name.

name.substring(name.length() - 1,name.length())

20874: Assume that word is a variable of type String that has been assigned a value. Write an expression whose value is a String consisting of the last three characters of the value of word.

word.substring(word.length()-3,word.length())

20875: Given the String variable address, write an expression that returns the position of the first occurrence of the String “Avenue” in address.

address.indexOf("Avenue")

Assume that sentence is a variable of type String that has been assigned a value. Assume furthermore that this value is a String consisting of words separated by single space characters with a period at the end. Assume that there is another variable declared, firstWord, also of type String. Write the statements needed so that the first word of the value of sentence is assigned to firstWord.

firstWord = sentence.substring(0,sentence.indexOf(' '));

20884: Assume that sentence is a variable of type String that has been assigned a value. Assume furthermore that this value is a String consisting of words separated by single space characters with a period at the end. For example: “This is a possible value of sentence.” Assume that there is another variable declared, secondWord, also of type String. Write the statements needed so that the second word of the value of sentence is assigned to secondWord. So, if the value of sentence were “Broccoli is delicious.” your code would assign the value “is” to secondWord.

int start = sentence.indexOf(" ") + 1;


int end = sentence.indexOf(" ", start+1);


secondWord = sentence.substring(start,end);

20883: Write a sequence of statements that finds the first comma in the String line, and assigns to the variable clause the portion of line up to, but not including the comma. You may assume that an int variable pos, as well as the variables line and clause, have already been declared.

pos = line.indexOf(',');
clause = line.substring(0,pos);

20969: Write a statement that reads a word from standard input into firstWord. Assume that firstWord has already been declared as a String variable. Assume also that stdin is a variable that references a Scanner object associated with standard input.

firstWord = stdin.next();

20971: Assume that name has been declared suitably for storing names (like “Misha”, “Emily” and “Sofia”). Assume also that stdin is a variable that references a Scanner object associated with standard input. Write some code that reads a value into name then prints the message “Greetings, NAME” on a line by itself, where NAME is replace the value that was read into name.

name = stdin.next();


System.out.println("Greetings, " + name);

20606: Given an int variable datum that has already been declared, write a few statements that read an integer value from standard input into this variable.

Scanner stdin = new Scanner( System.in);


datum = stdin.nextInt();

21152: Assume the availability of class name IMath that provides a static method, toThePowerOf is a method that accepts two int arguments and returns the value of the first parameter raised to the power of the second. An int variable cubeSide has already been declared and initialized. Another int variable, cubeVolume, has already been declared. Write a statement that calls toThePowerOf to compute the value of cubeSide raised to the power of 3 and that stores this value in cubeVolume.

cubeVolume = IMath.toThePowerOf(cubeSide, 3);

21010: The area of a square is stored in a double variable named area. Write an expression whose value is length of one side of the square.

Math.sqrt(area)

21011: The area of a square is stored in a double variable named area. Write an expression whose value is length of the diagonal of the square.

Math.sqrt(area*2)

Write an expression whose value is the largest of population1, population2, population3, and poplation4 by calling max.

Math.max(Math.max(population1,population2),Math.max(population3,population4))

20587: Suppose a reference variable of type Double called myDouble is already declared. Create an object of type Double with the initial value of 1.5 and assign it to the reference variable myDouble.

myDouble = new Double(1.5);

The _____ class allows non-GUI applications to interact with users using dialog boxes.

JOptionPane

The JOptionPane method that gets input from the user is

showInputDialog

Data returned by JOptionPane is always of the _____ type (excluding yes-or-no questions).

String