The result of 10/2.0 is A) an int B) a double C) a float D) a String E) none of the above
To save the result of 100 * Math.log(2.0) into a String, you can add the following in front of the expression A) String s = (String) B) String s = “” + C) String s = atoi( D) String s = ftoa( E) none of the above
The following will set x to be what value? x = (12>3) ? 12: 3 A) 12 B) 3 C) ¼ D) 4 E) none of the above
The result of x %= 3 when x starts off as 20 is A) 6 B) 6.66 C) 0 D) 2 E) none of the above
Of the following data types, which can have an integer copied into it without being explicitly cast? A) int B) boolean C) double D) both A and C E) A, B and C
Which of the following within a String allows one to add a single “ character to a String? A) “ B) “” C) \”” D) /” E) none of the above
Which of the following will calculate the squareroot of a double z? A) Math.square(z) B) z.sqrt() C) Math.pow(-2) D) Math.sqrt(z) E) none of the above
For the following questions write on your answer sheet T if the statement is true, f otherwise
If one has a method in a superclass and a subclass named the same, by default an object of the subclass type will call the superclass' version of the method
If you define a private class j within a class q, class j can only be used within class q.
Indexes in Strings in Java start counting at 1
It is impossible to cast an object of one class to an object
of another class.
A long variable can store values larger than what an int can hold
In order to extract a specific character in a String, you can use the getChar() method built into the String class.
While doubles store numbers, one cannot use all of the mathematical operators (such as + - * / and such) that one can use with integers.
compareTo returns a boolean value that lets you know only if two strings have exactly the same content or not
I am evil Homer! I am evil Homer!
For the following problems write out SHORT answers on your answer sheet
Given a string named s, write a single line of code that will convert the string into an integer named i (you can assume these variables exist) (worth 2 points)
Write a line of code that will translate an integer named q into a string called s1 (you can assume that these variables are already declared) (worth 1 point)
Set a double named glaven to the built in Java math value for PI * 2