Questions from Starting Out With Java


Q: How does the StringBuilder class’s replace method differ from the

How does the StringBuilder class’s replace method differ from the String class’s replace method?

See Answer

Q: The following string contains three tokens. What are they? What

The following string contains three tokens. What are they? What character is the delimiter? "apples pears bananas"

See Answer

Q: Look at the following code: String str = "one

Look at the following code: String str = "one two three four"; String[] tokens = str.split(" "); int x = tokens.length; String first = tokens[0]; What value will be stored in x? What value will the fi...

See Answer

Q: Look at the following string: "/home/rjones/

Look at the following string: "/home/rjones/mydata.txt" Write code using the String class’s split method that can be used to extract the following tokens from the string: home , rjones , mydata , an...

See Answer

Q: Look at the following string: "dog$cat@

Look at the following string: "dog$cat@bird%squirrel" Write code using the String class’s split method that can be used to extract the following tokens from the string: dog, cat, bird, and squirrel....

See Answer

Q: Write code that does the following: opens a file named NumberList

Write code that does the following: opens a file named NumberList.txt, uses a loop to write the numbers 1 through 100 to the file, and then closes the file.

See Answer

Q: Write a statement that converts the following integer to a string and

Write a statement that converts the following integer to a string and stores it in the String object referenced by str: int i = 99;

See Answer

Q: What is the output of the following statement? System.

What is the output of the following statement? System.out.println(Character.toUpperCase(Character.toLowerCase('A')));

See Answer

Q: What wrapper class methods convert a number from decimal to another numbering

What wrapper class methods convert a number from decimal to another numbering system? What wrapper classes are these methods a member of?

See Answer

Q: What is the purpose of the MIN_VALUE and MAX_

What is the purpose of the MIN_VALUE and MAX_VALUE variables that are members of the numeric wrapper classes?

See Answer