COSC 1437 - Test 3 - Chapters 6, 7, 8

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Which of the following statements opens a file named MyFile.txt and allows you to read data from it? A. File file = new File("MyFile.txt"); B. PrintWriter inputFile = new PrintWriter("MyFile.txt"); C. File file = new File("MyFile.txt"); Scanner inputFile = new Scanner(file); D. Scanner inputFile = new Scanner("MyFile.txt");

C

RAM is usually? A.A static type of memory, used for permanent storage B.Secondary Storage C.An input/output device D.A volatile type of memory, used only for temporary storage.

D

What will be the value of loc after the following code is executed? int loc; String str = "The cow jumped over the moon."; loc = str.lastIndexOf("ov", 14);

-1

What will be the value of position after the following code is executed? int position; String str = "The cow jumped over the moon."; position = str.lastIndexOf("ov", 14);

-1

If the following is from the method section of a UML diagram, which of the following statements is true? + equals(object2:Stock) : boolean A. This is a private method that returns a boolean value. B. This is a private method that receives two objects from the Stock class and returns a boolean value. C. This is a public method that accepts a Stock object as its argument and returns a boolean value. D. This is a public method that returns a reference to a String object.

...

Java automatically stores this value in all uninitialized static member variables: null 0 -1 false

0

What will be the tokens in the following statement? StringTokenizer strToken = new StringTokenizer("123-456-7890", "-", true);

123, 456, 7980, and -

What will be the value of loc after the following code is executed? int loc; String str = "The cow jumped over the moon."; loc = str.indexOf("ov");

15

What will be the value of position after the following code is executed? position=str.indexOf("ov");

15

The no-arg constructor for a StringBuilder object gives the object enough storage space to hold this many characters.

16 characters

For the following code, how many times would the while loop execute? StringTokenizer strToken = new StringTokenizer("Ben and Jerry's ice cream is great."); while (strToken.hasMoreTokens()) { System.out.println(strToken.nextToken()); }

7

For the following code, how many times would the while loop execute? StringTokenizer strToken = new StringTokenizer("Cars, trucks, and SUVs " + "are all types of automobiles."); while (strToken.hasMoreTokens()) { System.out.println(strToken.nextToken()); }

9

What will be the tokens in the following statement? StringTokenizer st = new StringTokenizer("9-14-2014", "-", true);

9, 14, 2014, and -

A characteristic of ________ is that only an object's methods are able to directly access and make the changes to the object's data. A.Data Hiding B.Classes C.Component Reusability D.Procedure

A

An object typically hides it data, but allows outside code to access? A.the methods that operate on the data B.the data files C.private data members D.the pseudocode

A

If you wish to use the System.out.printf method to print a string argument, use the ________ format specifier. A.%s B.%d C.%b D.%f

A

In general, there are two types of files: A. text and binary B. delimited and unlimited C. encrypted and unencrypted D.static and dynamic

A

What is a ragged array? A. a two-dimensional array where the rows have a different number of columns B. a two-dimensional array for which the number of rows is unknown C. a partially initialized two-dimensional array of ranged values D. a one-dimensional array for which the number of elements is unknown

A

What is the value of scores[2][3] in the following array? int[][] scores = { {88, 80, 79, 92}, {75, 84, 93, 80}, {98, 95, 92, 94}, {91, 84, 88, 96} }; A. 94 B. 95 C. 93 D. 84

A

Which of the following is a correct method header for receiving a two-dimensional array as an argument? A. public static void passMyArray(int[][] myArray) B. public static void passMyArray(array myArray) C. public static void passMyArray(int myArray) D. public static void passMyArray(int[]myArray1, int[]myArray2)

A

You can use the ________ method to replace an item at a specific location in an ArrayList. A. set B. add C. replace D. remove

A

int x = 5, y = 28; float z; z = (float) (y / x); A.5.6 B.5.60 C.5.0 D.3.0

A

javac MyClass.java Before entering the command, you must? A.Make sure you are in the same directory or folder where the MyClass.java file is located B. Save the program with the .comp extension C.Close all other Windows on your computer system. D.Execute the java.sun.com program

A

What will be the tokens in the following statement? String str = "red$green&blue#orange"; String tokens = str.split("[$&#]");

"red", "green", "blue", and "orange"

Look at the following declaration: enum Tree { OAK, MAPLE, PINE } What is the ordinal value of the MAPLE enum constant? 0 1 2 3 Tree.MAPLE

1

What is the result of the following expression? A.8 B.7 C.12 D.105

B

You cannot use the fully qualified name of an enum constant for this

a case expression

You cannot use the fully-qualified name of an enum constant for this. a switch expression an argument to a method a case expression all of these

a case expression

When an object is passed as an argument to a method, this is actually passed

a reference to the object

The process of matching a method call with the correct method is known as

binding

In the ________ file format, when the data in a spreadsheet is exported, each row is written to a line, and the values in the cells are separated by commas.

comma separated value

What is the value of str after the following code has been executed? String str; String sourceStr = "Hey diddle, diddle, the cat and the fiddle"; str = sourceStr.substring(12,17);

diddl

To convert the string, str = "285.74" to a double, use the following statement.

double x = Double.ParseDouble(str);

A declaration for an enumerated type begins with this key word. enum enum_type enumerated ENUM

enum

If str is declared as: String str = "ABCDEFGHI"; What will be returned from Character.toLowerCase(str.charAt(5))?

f

What will be the value of matches after the following code has been executed? boolean matches; String str1 = "The cow jumped over the moon."; String str2 = "moon"; matches = str1.endsWith(str2);

false

You cannot assign a value to a wrapper class object. (T/F)

false

If a class has this method, it is called automatically just before an instance of the class is destroyed by the JVM

finalize

The JVM periodically performs this process to remove unreferenced objects from memory. memory sweeping system restore memory shuffling garbage collection

garbage collection

The JVM periodically performs this process, which automatically removes unreferenced objects from memory

garbage collection

The term for the relationship created by object aggregation is: is a Sub-class object has a Inner class

has a

To use the StringTokenizer class you must have the following import statement.

import java.util.StringTokenizer;

Which of the following import statements is required to use the StringTokenizer class?

import java.util.StringTokenizer;

Which of the following import statements is required to use the StringTokenizer class? import java.text.DecimalFormat; import java.util.Scanner import javax.swing.JOptionPane; import java.util.StringTokenizer;

import java.util.StringTokenizer;

A class that is defined inside of another class is called a(n)

inner class or nesting

To convert the string, str = "285" to an int, use the following statement:

int x = Integer.parseInt(str);

Which of the following statements converts a String object variable named str to an int and stores the value in the variable x?

int x = Integer.parseInt(str);

Which of the following statements converts a String object variable named str to an int and stores the value in the variable x? int x = str; int x = Integer.integer(str); int x = Integer.parseInteger(str); int x = Integer.parseInt(str);

int x = Integer.parseInt(str);

A deep copy of an object: is always a private method is a bogus term, it has no meaning is an assignment of that object to another object is an operation that copies an aggregate object, and all the objects it references

is an operation that copies an aggregate object, and all the objects it references

What will be displayed after the following code has been executed? String str1 = "The quick brown fox jumped over the lazy dog."; String str2 = str1.substring(20, 26); System.out.println(str2);

jumped

Any ________ argument passed to the Character class's toLowerCase method or toUpperCase method is returned as it is.

nonletter

What will be displayed after the following code is executed? String str = "abc456"

not ABC

If you have defined a class named SavingsAccount with a public static data member named numberOfAccounts, and created a SavingsAccount object referenced by the variable account20, which of the following will assign numberOfAccounts to numAccounts? numAccounts = account20.numAccounts; numAccounts = numberOfAccounts; numAccounts = SavingsAccount.numberOfAccounts; None of these, you cannot reference a static data member.

numAccounts = SavingsAccount.numberOfAccounts;

You cannot use the == operator to compare the contents of: objects strings Boolean values integers

objects

This enum method returns the position of an enum constant in the declaration.

ordinal

return object from methods // ReturnObject.java

pg. 507 - 509

When an array is passed to a method A. it is passed just as any other object would be B. a reference to the array is passed C. the method has direct access to the original array D. All of the above

D

If a class has a method named finalize, it is called automatically just before a data member that has been identified as final of the class is destroyed by the garbage collector. True False

False

Use the following import statement when using the Character wrapper class:

No import statement is needed

Which of the following import statements is required to use the Character wrapper class?

No import statement is needed

Which of the following import statements is required to use the Character wrapper class? import java.lang.Char import java.String import java.Char No import statement is needed

No import statement is needed

Assuming the following declaration exists: enum Tree { OAK, MAPLE, PINE } What will the following code display? System.out.println(Tree.OAK); Tree.OAK 0 1 OAK Nothing. This statement will cause an error.

OAK

What will be displayed after the following statements are executed? StringBuilder strb = new StringBuilder("We have lived in Chicago, Trenton, and Atlanta."); strb.replace(17, 24, "Tampa"); System.out.println(strb);

We have lived in Tampa, Trenton, and Atlanta.

What will be displayed after the following statements are executed? Stringbuilder strb=

We have lived in Tampa, Trenton, and Atlanta.

In the following statement, what data type must recField be? str.getChars(5, 10, recField, 0);

char []

In the following statement, what data type must recField be?

char[]

In the following statement, what data type must recField be? str.getChars(5, 10, recField, 0);

char[]

What will be displayed after the following statements are executed? String str = "red$green$blue#orange";

red green blue orange

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

state

Static methods can only operate on ________ fields. global instance static local

static

This type of method cannot access any nonstatic member variables in its own class

static

What would be the results of executing the following code? StringBuilder str = new StringBuilder("Little Jack Horner "); str.append("sat on the "); str.append("corner");

str would reference "Little Jack Horner sat on the corner".

What would be the results of executing the following code? StringBuilder str = new StringBuilder(12); str.append("The cow"); str.append(" jumped over the "); str.append("moon.");

str would reference "The cow jumped over the moon."

The term ________ commonly is used to refer to a string that is part of another string.

substring

The Character wrapper class provides numerous methods for

testing and converting character data

The Character wrapper class provides numerous methods for

testing and converting character data.

Two or more methods in a class may have the same name, as long as this is different

their signatures

This is the name of a reference variable that is always available to an instance method and refers to the object that is calling the method.

this

A method A.may have only one parameter variables B.may have zero or more parameter variables C.must have at least two parameter variables D.never has parameter variables

B

A method's signature consists of A. the return type and the method name B.the method name and the parameter list C.the size of the method in memory D.the return type, the method name, and the parameter list

B

A(n) ________ is a special value that cannot be mistaken as a member of a list of data items and signals that there are no more data items from the list to be processed. A. terminator B. sentinel C. accumulator D. delimiter

B

A(n) ________ is used as an index to pinpoint a specific element within an array. Question options: A. boolean value B. subscript C. element D. range

B

An array of String objects A. must be initialized when the B. consists of an array of references to String objects C. is arranged the same as an array of primitive objects D. is compressed to 4 bytes for each element.

B

Enclosing a group of statements inside a set of braces creates A. an expression B. a block of statements C. an if-else statement D. a relational operator

B

If object1 and object2 are objects of the same class, to make object2 a copy of object1 Question options: A. use the copy method that is a part of the Java API. B. write a method for the class that will make a field by field copy of object1 data members into object2 data members. C. use an assignment statement to make object2 a copy of object1. D. use the default constructor to create object2 with object1 data members.

B

In the following Java statement what value is stored in the variable name? String name = "John Doe"; A."name" B.the memory address where "John Doe" is located C."John Doe" D.the memory address where name is located

B

The "has a" relationship is sometimes called a(n) ________ because one object is part of a greater whole. A. mutual relationship B. whole-part relationship C.possession D.enterprise

B

The JVM periodically performs this process to remove unreferenced objects from memory. A. system restore B.garbage collection C. memory shuffling D. memory sweeping

B

The ________ is ideal in situations where the exact number of iterations is known. A. posttest loop B. for loop C. do-while loop D. while loop

B

The ________ loop is ideal in situations where you always want the loop to iterate at least once. A. pretest B. do-while C. while D. for

B

final int x = 22, y = 4; y += x; System.out.println("x = " + x + ", y = " + y); A.x=22,y=88 B.x=22,y=26 C.x=22,y=4 D.Nothing.

B

int x = 5, y = 20; x += 32; y /= 4; System.out.println("x = " + x + ", y = " + y); A.x=160,y=80 B.x=37,y=5 C.x=32,y=4 D.x=9,y=52

B

A ________ is a boolean variable that signals when some condition exists in the program. A.case B.block C.flag D.sentinel

C

A block of code is enclosed in a set of A. parentheses B. double quotes C. braces D. brackets

C

A class's responsibilities include A.the things a class is responsible for doing. B.the things a class is responsible for knowing C.both a and b D.neither A nor B

C

A constructor A.has return type of void B.always accepts two arguments C.has the same name as the class D.always has an access specifier of private

C

Before entering a loop to compute a running total, the program should first A.read all the values into main memory. B. know exactly how many values there are to total. C. set the accumulator variable to an initial value, usually zero D. set all variable to zero.

C

The ________ method is used to display a message dialog. A.messageDialog B.showDialog C.showMessageDialog D.messageDialogshop

C

The boolean data type may contain the following range of values: A.-2,147,483,648 to +2,147,483,647 B.-32,762 to +32,767 C.true or false D.-128 to +127

C

To return an array of long values from a method, use this as the return type for the method. A. long[ARRAY_SIZE] B. long C. long[] D. array

C

What is the following statement an example of? import java.util.Scanner; A.a wildcard import statement B.a conditional import statement C.an explicit import statement D.an unconditional import statement

C

What will be displayed when the following code is executed? double x = 45678.259; DecimalFormat formatter = new DecimalFormat("#,##0.0"); JOptionPane.showMessageDialog(null,formatter.format(x)); A. 45,678.26 B. 45678.259 C. 45,678.259 D. 45,678.3

D

What will be returned from the method, if the following is the method header? public Rectangle getRectangle() A. the values stored in the data members of the Rectangle object B. a null value C. an object that is contained in the class Rectangle D. the address of an object of the Rectangle class

D

Which of the following statements opens a file named MyFile.txt and allows you to append data to its existing contents? A. PrintWriter outfile = new PrintWriter(true, "MyFile.txt"); B. FileWriter fwriter = new FileWriter("MyFile.txt"); PrintWriter outFile = new PrintWriter(fwriter); C. PrintWriter outfile = new PrintWriter("MyFile.txt", true); D. FileWriter fwriter = new FileWriter("MyFile.txt", true); PrintWriter outFile = new PrintWriter(fwriter);

D

________ operators are used to determine whether a specific relationship exists between two values. A. Assignment B. Logical C. Arithmetic D. Relational

D

What will be returned from the method, if the following is the method header? public Rectangle getRectangle() Question options: A. the values stored in the data members of the Rectangle object B. a null value C. an object that is contained in the class Rectangle D. the address of an object of the Rectangle class

D.

What is the term used for the character that separates tokens?

Delimiter

If a string has more than one character used as a delimiter, we must write a loop to determine the tokens, one for each delimiter character.

False

TRUE/FALSE: If a non-letter argument is passed to the toLowerCase or toUpperCase method, the boolean value false is returned.

False

TRUE/FALSE: If a string has more than one character used as a delimiter, we must write a loop to determine the tokens, one for each delimiter character.

False

TRUE/FALSE: StringBuilder objects are immutable.

False

TRUE/FALSE: The String class's valueOf() method accepts a string representation as an argument and returns its equivalent integer value.

False

TRUE/FALSE: The following statement correctly creates a StringBuilder object. StringBuilder str = "Caesar Salad";

False

TRUE/FALSE: You cannot assign a value to a wrapper class object.

False

TRUE/FALSE: You must call a method to get the value of a wrapper class object.

False

The String class's valueOf method accepts a string representation as an argument and returns its equivalent integer value.

False

The String class's valueOf method accepts a string representation as an argument and returns its equivalent integer value. (T/F)

False

The key word this is the name of a reference variable that an object can use to refer to itself. True False

False

The names of the enum constants in an enumerated data type must be enclosed in quotation marks. True False

False

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

False

True or False: A class may not have more than one constructor

False

True or False: A method cannot return a reference to an object

False

True or False: A static member method may refer to nonstatic member variables of the same class at any time.

False

True or False: All static member variables are initialized to -1 by default.

False

True or False: You can declare an enumerated data type inside a method.

False

True or False: enum constants have a toString method

False

You can declare an enumerated data type inside of a method. True False

False

Look at the following statement: StringBuilder str = new StringBuilder(25); What will the StringBuilder constructor do?

Give the object, str, 25 bytes of storage and not store anything in them

If you do not specify delimiters in the StringToken constructor, which of the following cannot be a delimiter?

Semicolon

Passing Objects as an argument // PassObject.java

Shows an example of how you can pass an object into an argument on page 504.

Passing Objects as an argument // PassObject2.java

Shows an example of how you can pass an object into an argument on page 506. The method modifies the contents of the object referenced by the variable.

Static Members

Static Fields and Static Methods are fields and methods that do not belong to any instance of a class. They belong in the same class and not an instance of a class.

Use of Static Methods

Static methods are convenient for many tasks because they can be called directly from the class, as needed. They are most often used to create utility classes that perform operations on data, but have no need to collect and store data.

To convert the double variable, d = 543.98, to a string, use the following statement:

String str = Double.toString(d);

Which of the following statements converts a double variable named tax to a string and stores the value in the String object variable named str?

String str = Double.toString(tax);

Which of the following statements converts a double variable named tax to a string and stores the value in the String object variable named str? String str = tax.Double.toString(str); String str = double.toString(tax); String str = double(tax); String str = Double.toString(tax);

String str = Double.toString(tax);

To convert the int variable, number to a string, use the following statement:

String str = Integer.toString(number);

Which of the following statements converts an int variable named number to a string and stores the value in the String object variable named str?

String str = Integer.toString(number);

If your program needs to make a lot of changes to one or more string, you might consider using objects of this class:

StringBuilder

The term ____________ commonly is used to refer to a string that is part of another string.

Substring

Which of the following statements will display the maximum value that a double can hold?

System.out.println(Double.MAX_VALUE);

Which of the following statements will print the maximum value a double variable may have?

System.out.println(Double.MAX_VALUE);

Which of the following statements will print the maximum value an int variable may have?

System.out.println(Integer.MAX_VALUE);

The Character wrapper class provides numerous methods for:

Testing and converting char variables

Assume the class BankAccount has been created, and the following statement correctly creates an instance of the class: BankAccount account = new BankAccount(5000.0); What is TRUE about the following statement? System.out.println(account); The account object's toString method will be implicitly called. A compiler error will occur. The method will display unreadable binary data on the screen. A runtime error will occur.

The account object's toString method will be implicitly called.

What will be returned from a method, if the following is the method header? public Rectangle getRectangle() An object of the class Rectangle The values stored in the data members of the Rectangle object the method changed A graph of a rectangle The address of an object of the class Rectangle

The address of an object of the class Rectangle

What will be displayed after the following statements are executed? StringBuilder strb = new StringBuilder (12);

The cow jumped over the moon.

Given the following statement, which of the following is not true? str.insert(8, 32);

The insert will start at position 32

An instance of a class does not have to exist in order for values to be stored in a class's static fields. True False

True

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 False

True

Enum constants have a toString method. True False

True

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 False

True

Most of the String comparison methods are case sensitive.

True

StringBuilder objects are not immutable.

True

TRUE/FALSE: If a non-letter is passed to the toLowerCase or toUpperCase method, it is returned unchanged.

True

TRUE/FALSE: If you are using characters other than whitespaces as delimiters, you will probably want to trim the string before tokenizing; otherwise, the leading and/or following whitespaces will become part of the first and/or last token.

True

TRUE/FALSE: The String class's valueOf() method accepts a value of any primitive data type as an argument and returns a string representation of the value.

True

TRUE/FALSE: The wrapper classes in Java are immutable, which means that once you create an object, you cannot change the object's value.

True

TRUE/FALSE: You can change the contents of a StringBuilder object, but you cannot change the contents of a String object.

True

True or False: A private class that is defined inside another class is not visible to code outside the outer class.

True

True or False: Enumerated data types are actually special types of classes.

True

True or False: When an object is passed as an argument to a method, the method can access the argument

True

Trying to extract more tokens than exist from a StringTokenizer object will cause an error.

True

When working with the String and StringBuilder class's getChars method, the character at the start position is included in the substring, but the character at the end position is not included.

True

You will cause an off-by-one error, when working with a character position within a string, if you think of the first position in a string as 1.

True

This is the process of converting a wrapper class object to a primitive type.

Unboxing

Two ways of concatenating two Strings are:

Use the concat method or use the + between the two Strings

Assuming that str is declared as follows, String str = "RSTUVWXYZ"; What value will be returned from str.charAt(5)?

W

What will be displayed after the following code is executed? String str = "RSTUVWXYZ";

W

A static field is created by placing: the key word static after the field name the key word static after the access specifier and before the field's data type the key word static after the access specifier and field's data type it in a static field block

the key word static after the access specifier and before the field's data type

The toString Method

the method returns a string that represents the state of an object. state: the data that is stored in the object's fields at any given moment.

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

toString

A series of words or other items of data separated by spaces or other characters are known as

tokens

The ________ method returns a copy of the calling String object, in which all leading and trailing whitespace characters have been deleted.

trim

Trying to extract more tokens than exist from a StringTokenizer object will cause an error. (T/F)

true

You will cause an off-by-one error, when working with a character position within a string, if you think of the first position in a string as 1. (T/F)

true

You can concatenate String objects by

using the concat method or the + operator.

The String class's ________ method accepts a value of any primitive data type as its argument and returns a string representation of the value.

valueOf

Which Scanner class method reads a String? A.nextString B.nextLine C.getLine D.charAt

B

What will be the value of position after the following code is executed? position=str.lastIndexOf("ov",14);

NOT 1

If object1 and object2 are objects of the same class, to make object2 a copy of object1: use the Java copy method that is a part of the Java language assign object1 to object2, such as object2 = object1; use the default constructor to create object2 with object1 data members write a copy method that will make a field by field copy of object1 data members into object2 data members

write a copy method that will make a field by field copy of object1 data members into object2 data members

To compare two objects in a class: Since objects consist of several fields, you cannot compare them write a method to do a byte-by-byte compare of the two objects write an equals method that will make a field by field compare of the two objects use the == operator, e.g. object1 == object2

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

When a method's return type is a class, what is actually returned to the calling program? An object of that class A reference to an object of that class Only the values in the object that the method accessed Nothing, the return type is strictly for documentation in this situation.

A reference to an object of that class

Static Class Members

A static class member belongs to the class, not objects instantiated from the class

Static Methods

A static method is created by placing the key word static after the access specifier in the method header. Because they are declared as static, they belong to the class and may be called without any instances of the class being in existence.

When using the StringBuilder class's insert method, you can insert:

All of the above (Any primitive type, a String object, & a char array)

What does the following statement do? Double number = new Double(8.8);

All of the above (It creates a Double object, It initializes that object to 8.8, & It assigns the object's address to the number variable)

What does the following statement do? Float number = new Float(8.8);

All of the above (It creates a Float object, It initializes that object to 8.8, & It assigns the object's address to the number variable)

The sequential search algorithm A. requires the array to be in ascending ordered B. uses a loop to sequentially step through an array,starting with the first element C. returns 1 if the value being search for is found, otherwise it returns -1. D. All of the above

B

This is a special language used to write computer programs. A.Application B.Programming Language C.Pseudocode D.Operating System

B

This statement tells the compiler where to find the JOptionPane class and makes it available to your program. A. import javax.JOptionPane; B.Import javax.swing.JOptionPane; C.import JOptionPance; D.import Java.Swing.JOptionPane;

B

You can use the enum key word to A. specify the values that belong to that type B. create your own data type C. Both A and B

C

You may use this to compare two enum data values. A. the==,> and < operators B.the moreThan, lessThan and equalsTo methods C. the equals and compareTo methods D. the ordinal method

C

If the following is from the method section of a UML diagram, which of the following statements is true? + equals(object2:Stock) : boolean Question options: A. This is a private method that returns a boolean value. B.This is a private method that receives two objects from the Stock class and returns a boolean value. C.This is a public method that accepts a Stock object as its argument and returns a boolean value. D. This is a public method that returns a reference to a String object.

C.

Assuming the following declaration exists: enum Seasons { SPRING, WINTER, SUMMER, FALL } what is the fully qualified name of the FALL constant

Seasons.FALL

The ________ class is the wrapper class for the char data type.

Character

CRC stands for

Class, Responsibilities, Collaborations

"Blank" is a cross between human language and a programming language. A. Java B. The Java Virtual Machine C. The compiler D. Pseudocode

D

A loop that executes as long as a particular condition exists is called a(n) ________ loop. A. infinite B. count-controlled C. relational D. conditional

D

Another term for an object of a class is a(n) A.access specifier B.member C.method D.instance

D

Class objects normally have ________ that perform useful operations on their data, but primitive variables do not. A.instances B.relationships C.fields D.methods

D

Enumerated types have this method, which returns the position of an enum constant in the declaration list. A.index B.position C.location D.ordinal

D

Given the following two-dimensional array declaration, which statement is true? int[][] numbers = new int[6][9]; A. The numbers array has 54 rows. B. The numbers array has 6 columns and 9 rows. C. The numbers array has 15 rows. D. The numbers array has 6 rows and 9 columns.

D

Methods that operate on an object's fields are called A. private methods B.instance variables C.public methods D.instance methods

D

One or more objects may be created from a(n) A. method B.field C.instance D.class

D

The only limitation that static methods have is A. they must be declared outside of the class B. they can only be called from static members of the class C. they can refer to only nonstatic members of the class D. they cannot refer to nonstatic members of the class

D

The original name for Java was? A.*7 B.HotJava C. Elm D. Oak

D

This is a set of programming language statements that, together, perform a specific task. A.Object B.Compile C.Pseudocode D.Procedure

D

This type of loop will always be executed at least once. A. infinite B. pretest C. conditional D. posttest

D

Which of the following is NOT true about static methods? They are created by placing the key word static after the access specifier in the method header. They are called directly from the class. They are often used to create utility classes that perform operations on data, but have no need to collect and store data. It is necessary for an instance of the class to be created to execute the method.

It is necessary for an instance of the class to be created to execute the method.

Autoboxing is:

Java's process of automatically "boxing up" a value inside an object

Look at the following code. Integer myNumber; myNumber = 5; Which of the following is true about the second statement?

The statement performs autoboxing.

Look at the following code: Integer myNumber = new Integer(5); int var = myNumber; Which of the following is true about the second statement?

The statement performs unboxing.

What will be the tokens in the following statement? StringTokenizer strToken = new StringTokenizer("January 1, 2008", ", ", true);

The tokens will be: January space 1 , space 2008

Which of the following is NOT true about static methods? They are created by placing the key word static after the access specifier in the method header. They are called from an instance of the class. They are often used to create utility classes that perform operations on data, but have no need to collect and store data. It is not necessary for an instance of the class to be created to execute the method.

They are called from an instance of the class.

Each of the numeric wrapper classes has a static ____________ method that converts a number to a string.

ToString

The process of breaking a string down into tokens is known as what?

Tokenizing

Sometimes a string will contain a series of words or other items of data separated by spaces or other characters. In programming terms, items such as these are known as what?

Tokens

This character is one that appears at the end, or right side, of a string, after the non-space characters:

Trailing whitespace

When you are writing a program with String objects that may have unwanted spaces at the beginning or end of the strings, use this method to delete them.

Trim

A single copy of a class's static field is shared by all instances of the class. True False

True

Static Fields

When a field is declared with the key word static, there will be only one copy of the field in memory, regardless of the number of instances of the class that might exist. It is shared amongst all instances of the class.

What is term used for a class that is "wrapped around" a primitive data type and allows you to create objects instead of variables?

Wrapper class

Making an instance of one class a field in another class is called

aggregation

Which of the following are used as delimiters if the StringTokenizer class's constructor is called and a reference to a String object is passed as the only argument? newline space tab

all of the above


Set pelajaran terkait

CHAPTER 7: antibacterial drugs that disrupt the bacterial cell wall

View Set

CompTIA A+ 1001 textbook practice questions

View Set

High School Biology Unit 5 Photosynthesis and Cellular Respiration Review Part 2

View Set

intro to international business (mc)

View Set

Diverticulosis and Diverticulitis

View Set

Mastering A & P Bone tissue, histology and muscle tissue

View Set