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;
100 Cards in this Set
- Front
- Back
Are String objects and reference variables immutable? |
String objects are immutable, but String reference variables are NOT |
|
What must you do after creating a new String to avoid it being lost to your program? |
You must assign somthing to the new String |
|
What happens to the old String if you redirect a String reference to a new String? |
The old String can be lost |
|
String methods use what based indexes? |
zero-based indexes |
|
Only exceptions for zero-based indexes |
Second argument in substring() |
|
Why can't the methods of the String class be overridden? |
The String class is final |
|
length() vs. length |
|
|
StringBuffer's API vs. StringBuilder's API |
They're the same, except that StringBuilder's methods are NOT synchronized for thread safety |
|
Which methods run faster between StringBuffer and StringBuilder? |
StringBuilder's methods should run faster |
|
True or False? Both StringBuffer and StringBuilder are NOT mutable? |
False. They are both mutable - they can change without creating a new object |
|
String Buffer and StringBuilder methods act on... |
the invoking object, and objects can change without an explicit assignment in the statement |
|
StringBuffer and StringBuilder equals() is NOT overridden, but it doesn't... |
compare values |
|
Chained methods are evaluated from... |
left to right |
|
String method charAt() |
Returns the character located at the String's specified index. REMEMBER indexes are zero-based |
|
String method concat() |
Returns a String with the value of the String passed in to the method appended to the end of the String used to invoke the method. The overloaded + and += perform functions similar. |
|
String method equalsIgnoreCase() |
Returns a boolean value depending on whether the value of the String in the argument is the same as the value of the String used to invoke the method. *Will return true even when characters being compared have differing cases |
|
String method length() |
Returns the number of characters in a String |
|
String method replace() |
Replaces occurrences of a character with a new character. replace(char old, char new) |
|
String method substring() |
|
|
String method toLowerCase() |
Returns a string with uppercase characters converted |
|
String method toString() |
Returns the value of a String |
|
String method trim() |
Returns a String whose value is the string used to invoke the method, but WITH any leading or trailing blank spaces REMOVED |
|
StringBuffer method append(String s) |
Will update the value of the object that invoked the method, whether or not the return is assigned to a variable. Similar to the + with Strings |
|
StringBuilder method delete(int start, int end) |
Returns a StringBuilder object and updates the value of the StringBuilder object that invoked. First argument is ZERO-Based Second argument is ONE-Based |
|
StringBuilder method insert(int offset, String s) |
Returns a StringBuilder object and updates the value of the object that invoked the method. ZERO-Based argument |
|
String vs StringBuffer objects What will the output be? StringBuffer sb = new StringBuffer ("abc"); sb.append("def"); System.out.println( sb ); |
"abcdef" |
|
StringBuffer method reverse() |
Reverses the characters in the StringBuffer object |
|
StringBuffer method toString() |
Returns the value of the StringBuffer object that invoked the method call as a String |
|
I/O class File |
An abstract representation of file and directory path names. It's used to work at a higher level, making new empty files, searching for files, deleting files, making directories, and working with paths |
|
I/O class FileReader |
|
|
I/O class BufferedReader |
|
|
I/O class FileWriter |
|
|
I/O class BufferedWriter |
|
|
I/O class PrintWriter |
|
|
I/O class Console |
Provides methods to read input from the console and write formatted output to the console |
|
True or False? A new File means there's a new file on your hard drive |
False |
|
File objects can represent either a ________ or a ________ |
file directory |
|
The File class lets you do what to files and directories? |
Manage them (add, rename, and delete) |
|
createNewFile() and mkdir() |
Add entries to your file system |
|
FileWriter and FileReader are ______-level I/O classes. You can use them to _________ and ________ files, but they should usually be ________ |
low read write wrapped |
|
True or False? Classes in java.io are designed NOT to be "chained" or "wrapped" |
False |
|
What is a common way to get access to higher-level (more convenient) methods? |
By "wrapping" a BufferedReader around a FileReader or a BufferedWriter around a FileWriter. |
|
This Java 5 I/O class has methods append(), format(), and printf() |
PrintWriters |
|
Console objects can read non-echoed input and are instantiated how? |
Using System.console() |
|
Serialization |
"Save this object and all of its instance variables...unless I've explicitly marked a variable as transient, which means don't include that variable's value as part of the object's serialization |
|
The classes you need to understand for Serialization (4) |
|
|
What must a class do before its objects can be serialized? |
Implement Serializable |
|
ObjectOutputStream.writeObject() method does what? |
Serializes objects |
|
ObjectInputStream.readObject() method does what? |
Deserializes objects |
|
What happens if you mark an instance variable transient? (in regards to serialization) |
It will NOT be serialized even though the rest of the object's state will be |
|
You can supplement a class's automatic serialization process by implementing what methods? |
writeObject() readObject() |
|
If a superclass implements Serializable then what do its subclasses do? |
Implements Srializable automatically |
|
What happens if a superclass doesn't implement Serializable when a subclass object is deserialized? |
The superclass constructor will be invoked, along with its superconstructor(s) |
|
java.util.Date class |
Use this class to bridge between Calendar and DateFormat class. Instance of Date represents a mutable date and time |
|
java.util.Calendar class |
Provides a variety of methods that help you convert and manipulate dates and times |
|
java.text.DateFormat class |
Used to format dates Various styles like "01/01/70" or "January 1, 1970" Format dates for numerous locales around the world |
|
java.text.NumberFormat class |
Used to format numbers and currencies for locals around the world |
|
java.until.Locale class |
Used in conjunction with DateFormat and NumberFormat to format dates, numbers and currency for specific locales. |
|
How is a Date stored? |
As a long, the number of milliseconds since January 1, 1970 |
|
Date objects are go-betweens what two classes? |
Calendar and Locale |
|
What do the methods of Calendar provide? |
Methods to manipulate dates, getting days of week, or adding some number of months or years to a date |
|
How to create Calendar instances? |
Using static factory methods (getInstance()) |
|
Calendar method add() |
Allows you to add or subtract various pieces (minutes, days, years...) to a date |
|
Calendar method roll() |
Works like add() except it doesn't increment a date's bigger pieces. (Adding 10 months to Oct changes the month to Aug but not the year) |
|
How to create DateFormat instances? |
Using static factory methods (getInstance() and getDateInstance()) |
|
How to create a wide array of outputs for any given date? |
DateFormat styles can be applied against various Locales |
|
DateFormat.format() method is used to create? |
Strings containing properly formatted dates |
|
The Locale class is used in conjunction with which two classes? |
DateFormat and NumberFormat |
|
Both DateFormat and NumberFormat objects can be constructed with? |
A specific, immutable Locale |
|
Regular Expressions (regex) are the patterns... |
used to search for data within large data structures |
|
regex lets you create search patterns using... |
literal characters or metacharacters (metacharacters allow you to search for slightly more abstract data like "digits" or "whitespace" |
|
Searches using Metacharacters /d |
A digit |
|
Searches using Metacharacters /s |
A whitespace character |
|
Searches using Metacharacters /w |
A word character (letters, digits, or "_" (underscore)) |
|
Searches using Metacharacters . |
the "." (dot) means "any character can serve here" source: "ac abc a c" pattern: a.c output 3 abc 7 a c |
|
regex provides for quantifiers which allow you to... |
specify concepts like: "look for one or more thing in a row" |
|
Greedy quantifier + |
Find one or more of the things in a row source: "1 a12 234b" pattern: /d+ output 0 1 3 12 6 234 |
|
Greedy quantifier * |
Zero or more occurrences |
|
Greedy quantifier ? |
Zero or ONE occurrences |
|
How do we fix the problem that metacharacters and Strings don't mix well? |
We add another backslash in front of the metacharacter Ex. "//d" instead of "/d" |
|
Which classes have Java's most powerful regex capabilities? |
Pattern and Matcher classes |
|
Tokenizing is the process of... |
splitting delimited data into small pieces |
|
How to create a Matcher? |
Use the Pattern.matcher() method (that takes String sourceData) |
|
In tokenizing, the data you want is called_______ |
tokens |
|
In tokenizing, the strings that separate the tokens are called..... |
delimiters |
|
How can tokenizing be done? 2 ways |
With the Scanner class or with String.split() |
|
True or False? Delimiters are multiple characters? |
False. They are single characters like commas, or complex regex expressions |
|
What does the Scanner class allow you to do that allows you to stop whenever you want to? |
Allows you to tokenize the data from within a loop |
|
The Scanner class allows you to tokenize these 3 things... |
|
|
Why might the String.split() method be slow at processing large amounts of data? |
It tokenizes the entire source data all at once |
|
Two methods used to format data for output. Found int eh PrintStream class, an instance or which is the out in System.out |
format() printf() |
|
format() and printf() methods are... |
identical |
|
How do you format data with printf() or format()? |
With FORMATTING STRINGS that are associated with primitive or string arguments |
|
format() allows you to mix... |
literals in with your format strings |
|
Format strings values to should know are FLAGS: -,+,0, "," and ( |
|
|
Clue to determining whether you're looking at formatting data... |
Formatting data will always start with a percent sign (%) |
|
Format string values you should know are CONVERSIONS: b, c, d, f and s |
|
|
int i1 = -123 int i2 = 12345 System.out.printf(">%1$(7d< /n", i1); System.out.printf(">%0, 7d< /n", i2); |
Output > (123) < >012,345< |
|
2$ and 1$ in formatting with printf() and format() |
2$ represents the second argument 1$ represents the first argument |
|
What happens if your conversion character doesn't match your argument type? |
An exception will be thrown |