Which of the following is used to indicate a new line t
Which of the following is used to indicate a new line?
\\\'
\\\"
\
\\t
\\\\
Which of the following is a legal variable name in Java?
test.1
the answer
char
ans
3average
Assuming that scan is a properly initialized Scanner variable, which of the following correctly inputs a String?
String val = scan.nextValue();
String val = scan.nextInt();
String val = scan.nextDouble();
String val = nextDouble();
String val = scan.nextLine();
Which of the following is NOT a primitive data type?
All of the above are primitive data types
double
int
String
char
Put the following data types in order from smallest to largest (in terms of memory used).
double, char, int, String
int, char, double, String
char, int, double, String
double, int, char, String
int, double, char, String
Which of the following is modular division NOT used for?
time calculations
testing even and odd numbers
converting decimals to whole numbers
money calculations
patterns
What is ( 6 % 2 ) * 7?
0
1
7
14
21
What is output?
System.out.println(\"The answer is: \" + 5 + 19);
The answer is: 519
The answer is: 19
The answer is: 24
The answer is: 5 19
Error - Strings cannot do calculations.
Consider the following code:
int c = 3 – 37 % 2;
System.out.println ( c );
What is output?
-18
2
3
8
15.5
Which of the following variable assignments is legal in Java?
double n = 3;
int x = 5.0/2;
String w = 82.5;
int q = 82.3847;
char l = \"G\";
Which character below is not allowed in a variable name?
_
W
q
3
&
Which is the best way to avoid roundoff error?
Use booleans for calculations.
Convert double values to ints and do calculations using integers.
Convert int values to doubles and do calculations using doubles.
Convert char values to doubles and do calculations using doubles.
Do all calculations using doubles.
Which of the following correctly stores the word umbrella in a variable called stuff?
String umbrella = \"stuff\";
String \"stuff\" = \"umbrella\";
String stuff = umbrella;
String stuff = \"umbrella\";
String umbrella = stuff;
What is wrong with the following code?
double x = 7.4549;
The decimal portion will be truncated.
Decimals can only have 2 places.
Floats cannot be inputted from the keyboard with out using the wrapper classes.
You must cast since integers hold less information than doubles.
There is nothing wrong.
Which of the following would properly create A and B as integer variables?
A, B int;
int A B;
int A, B;
int A; B;
int AB;
Consider the following code:
double x = -97.6;
System.out.println(Math.abs(x));
What is output?
-98
-97.6
-96
97.6
98
What is the result of compiling and running the following code?
int s = Math.sqrt(26);
5
5.0
5.09901951359278
6
Error: possible loss of precision
Correct the following code:
char q = -82;
char q = (char)Math.sqrt(-82);
char q = int(-82);
char q =(int) -82;
char q =(char)Math.abs(-82);
No changes, the code is fine.
Consider the following variable declaration:
int val = 13.2;
Does this need a cast to avoid a compiler error? ______ If so, what should you type to cast? ______
no, none
yes, (decimal)
yes, (double)
yes, (int)
yes, (String)
What is output?
int x = 9;
System.out.println( x / 2);
0
4
4.5
5
9
Solution
Answer:
Which of the following is used to indicate a new line?
\
Which of the following is a legal variable name in Java?
Char
Assuming that scan is a properly initialized Scanner variable, which of the following correctly inputs a String?
String val = scan.nextLine();
Which of the following is NOT a primitive data type?
String




