Your Name:

7.1 If name is a String variable, which expression will correctly return the first position of the letter 'e' if it exists?

(a) name.indexOf('e')
(b) name.startsWith('e')
(c) indexOf(name,'e')
(d) name.charAt('e')

7.2 If we have the data '$567.89' in the string price, how would we get the cents as a string?

(a) price.substring(price.indexOf('.'), price.length()-1);
(b) price.startsWith('.',price.endsWith('9'));
(c) price.substring(price.indexOf('.')+1,price.length())
(d) price.substring('.',price.length);

7.3 If tragic is a Calendar object, how would we set it to 31 August 1997?

(a) tragic.set(1997,Calendar.August,31);
(b) tragic.set(31, 8, 1997);
(c) tragic.set (1997, 8, 31);
(d) tragic.set (1997, Calendar.AUGUST, 31);

7.4 To read in 10 digit cheque numbers properly, we had to first read a string and convert it to a char array. Why?

(a) there is no readChar method in the Stream class
(b) chars have to be followed by spaces when read
(c) 10 digits is too long to read as an integer
(d) we can't compare strings and characters

7.5 If a string and a tokenizer are set up with

String s = "A678230056 7";
StringTokenizer T = new StringTokenizer(s, "0123456789", false);

what will the tokens be if we loop through all of them?

(a) A67230056 and 7
(b) 7
(c) A and 7
(d) A and space

7.6 If we have a price as an int and want to put it in a hash table, it has to be wrapped up as an object. The expression to do this is:

(a) (Integer) price
(b) new Integer (price)
(c) price.Intvalue()
(d) Integer (price)

7.7 In the Stream class, the format methods are declared as static because

(a) they deal with output, not input
(b) they are not related to any Stream object
(c) there are two of them with the same name
(d) they do raise IOExceptions

7.8 What will be printed after the following sequence?

NumberFormat N = NumberFormat.getInstance();
System.out.println(N.format(Math.PI)+" "+ N.format(10000));

(a) 3.1416 10000
(b) 0003.1416 10000
(c) 3.1416 10000.0000
(d) 3 10000

7.9 A locale can be set by

(a) a Java program
(b) the user via the operating system
(c) both of these
(d) neither of these

7.10 If our Locale is set to Germany, and we type in a date such as 07-May-2000 what will happen if we are using parsing on a DateFormat?

(a) the computer interprets it the date as intended, i.e. 7-5-2000
(b) a parseException is raised
(c) May defaults to zero, i.e. January
(d) we are asked to enter the date again