Deck 2: Java Fundamentals

Full screen (f)
exit full mode
Question
What will be displayed as a result of executing the following code? int x = 5, y = 20;
X += 32;
Y /= 4;
System.out.println("x = " + x + ", y = " + y);

A) x = 32, y = 4
B) x = 9, y = 52
C) x = 37, y = 5
D) x = 160, y = 80
Use Space or
up arrow
down arrow
to flip the card.
Question
In Java, ___________ must be declared before they can be used.

A) Variables
B) Literals
C) Key words
D) Comments
Question
To compile a program named First, use the following command:

A) java First.java
B) javac First
C) javac First.java
D) compile First.javac
Question
In Java, the beginning of a comment is marked with:

A) //
B) ""
C) ;
D) #
Question
What would be printed out as a result of the following code? System.out.println("The quick brown fox" +
"jumped over the \n"
"slow moving hen.");

A) The quick brown fox jumped over the \nslow moving hen.
B) The quick brown fox jumped over the
Slow moving hen.
C) The quick brown fox
Jumped over the
Slow moving hen.
D) Nothing. This is an error.
Question
What is the result of the following expression? 10 + 5 * 3 - 20

A) -5
B) 5
C) 25
D) -50
Question
Which of the following cannot be used as identifiers in Java?

A) Variable names
B) Class names
C) Key words
D) All of the above
E) None of the above
Question
What is the result of the following expression? 25 / 4 + 4 * 10 % 3

A) 19
B) 5.25
C) 3
D) 7
Question
When the + operator is used with strings, it is known as the:

A) Assignment operator
B) String concatenation operator
C) Addition operator
D) Combined assignment operator
Question
The term ___________ typically refers to the device that displays console output.

A) Standard output device
B) Central processing unit
C) Secondary storage device
D) Liquid crystal display
Question
Which of the following is valid?

A) float y;
Y = 54.9;
B) float y;
Double z;
Z = 934.21;
Y = z;
C) float w;
W = 1.0f;
D) float v;
V = 1.0;
Question
This is a value that is written into the code of a program.

A) literal
B) assignment statement
C) variable
D) operator
Question
The boolean data type may contain values in the following range of values

A) true or false
B) -128 to + 127
C) - 2,147,483,648 to +2,147,483,647
D) - 32,768 to +32,767
Question
Which of the following is not a rule that must be followed when naming identifiers?

A) The first character must be one of the letters a-z, A-Z, and underscore or a dollar sign.
B) Identifiers can contain spaces.
C) Uppercase and lowercase characters are distinct.
D) After the first character, you may use the letters a-z, A-Z, the underscore, a dollar sign, or digits 0-9.
Question
Character literals are enclosed in _____; string literals are enclosed in _____.

A) single quotes; single quotes
B) double quotes; double quotes
C) single quotes; double quotes
D) double quotes; single quotes
Question
Which one of the following would contain the translated Java byte code for a program named Demo?

A) Demo.java
B) Demo.code
C) Demo.class
D) Demo.byte
Question
A Java program must have at least one of these:

A) Class definition
B) Variable
C) Comment
D) System.out.println(); statement
Question
In Java, it is standard practice to capitalize the first letter of:

A) Class names
B) Variable names
C) Key words
D) Literals
Question
If the following Java statements are executed, what will be displayed? System.out.println("The top three winners are\n");
System.out.print("Jody, the Giant\n");
System.out.print("Buffy, the Barbarian");
System.out.println("Adelle, the Alligator");

A) The top three winners are
Jody, the Giant
Buffy, the Barbarian
Adelle, the Alligator
B) The top three winners are
Jody, the Giant\nBuffy, the BarbarianAdelle, the Alligator
C) The top three winners are Jody, the Giant\nBuffy, the BarbarianAdelle, and the Albino
D) The top three winners are
Jody, the Giant
Buffy, the BarbarianAdelle, the Alligator
Question
Which of the following is not a primitive data type?

A) short
B) long
C) float
D) String
Question
Every Java application program must have

A) a class named MAIN
B) a method named main
C) comments
D) integer variables
Question
What will be displayed as a result of executing the following code? int x = 6;
String msg = "I am enjoying this class.";
String msg1 = msg.toUpperCase();
String msg2 = msg.toLowerCase();
Char ltr = msg.charAt(x);
Int strSize = msg.length();
System.out.println(msg);
System.out.println(msg1);
System.out.println(msg2);
System.out.println("Character at index x = " +
Ltr);
System.out.println("msg has " + strSize +
"characters.");

A) I am enjoying this class.
I AM ENJOYING THIS CLASS.
I am enjoying this class.
Character at index x = e
Msg has 24 characters.
B) I am enjoying this class.
I AM ENJOYING THIS CLASS.
I am enjoying this class.
Character at index x = e
Msg has 25 characters.
C) I am enjoying this class.
I AM ENJOYING THIS CLASS.
I am enjoying this class.
Character at index x = n
Msg has 24 characters.
D) I am enjoying this class.
I AM ENJOYING THIS CLASS.
I am enjoying this class.
Character at index x = n
Msg has 25characters.
Question
What is the result of the following expression? 17 % 3 * 2 - 12 + 15

A) 7
B) 8
C) 12
D) 105
Question
The primitive data types only allow a(n) _____ to hold a single value.

A) variable
B) object
C) class
D) literal
Question
What will be displayed as a result of executing the following code? public class test
{
Public static void main(String[] args)
{
Int value1 = 9;
System.out.println(value1);
Int value2 = 45;
System.out.println(value2);
System.out.println(value3);
Value = 16;
}
}

A) 9
45
16
B) 94516
C) 9 45 16
D) Nothing, this is an error
Question
What is the result of the following expression? 25 - 7 * 3 + 12 / 3

A) 6
B) 8
C) 10
D) 12
Question
If x has been declared an int, which of the following statements is invalid?

A) x = 0;
B) x = -58932;
C) x = 1,000;
D) x = 592;
Question
Variables of the boolean data type are useful for

A) working with small integers
B) evaluating true/false conditions
C) working with very large integers
D) evaluating scientific notation
Question
To display the output on the next line, you can use the println method or use this escape sequence in the print method.

A) \n
B) \r
C) \t
D) \b
Question
What would be displayed as a result of the following code? int x = 578;
System.out.print("There are " +
X + 5 + "\n" +
"hens in the hen house.");

A) There are 583 hens in the hen house.
B) There are 5785 hens in the hen house.
C) There are x5\nhens in the hen house.
D) There are 5785
Hens in the hen house.
Question
What will be displayed after the following statements have been executed? int x = 15, y = 20, z = 32;
X += 12;
Y /= 6;
Z -= 14;
System.out.println("x = " + x +
", y = " + y +
", z = " +z);

A) x = 27, y = 3.333, z = 18
B) x = 27, y = 2, z = 18
C) x = 27, y = 3, z = 18
D) x = 37, y = 14, z = 4
Question
This is a named storage location in the computer's memory.

A) Literal
B) Constant
C) Variable
D) Operator
Question
What will be the displayed when the following code is executed? final int x = 22, y = 4;
Y += x;
System.out.println("x = " + x +
", y = " + y);

A) x = 22, y = 4
B) x = 22, y = 26
C) x = 22, y = 88
D) Nothing, this is an error
Question
Which of the following is not a valid comment statement?

A) // comment 1
B) /* comment 2 */
C) */ comment 3 /*
D) /** comment 4 */
Question
Variables are classified according to their

A) value
B) data type
C) names
D) location in the program
Question
In the following Java statement what value is stored in the variable name? String name = "John Doe";

A) John Doe
B) The memory address where "John Doe" is located
C) name
D) The memory address where name is located
Question
What will be the value of z as a result of executing the following code? int x = 5, y = 28;
Float z;
Z = (float) (y / x);

A) 5.60
B) 5.6
C) 3.0
D) 5.0
Question
What will be the value of z after the following statements have been executed? int x = 4, y = 33;
Double z;
Z = (double) (y / x);

A) 8.25
B) 4
C) 8
D) 8.0
Question
To print "Hello, world" on the monitor, use the following Java statement

A) SystemOutPrintln("Hello, world");
B) System.out.println{"Hello, world"}
C) System.out.println("Hello, world");
D) Print "Hello, world";
Question
Given the declaration double r;, which of the following statements is invalid?

A) r = 326.75;
B) r = 9.4632e15;
C) r = 9.4632E15;
D) r = 2.9X106;
Question
Both character literals and string literals can be assigned to a char variable.
Question
In Java the variable named total is the same as the variable named Total.
Question
Which of the following is a valid Java statement?

A) String str = 'John Doe';
B) string str = "John Doe";
C) string str = 'John Doe';
D) String str = "John Doe";
Question
A variable's scope is the part of the program that has access to the variable.
Question
Which Scanner class method reads a String?

A) readString()
B) nextString()
C) getString()
D) nextLine()
Question
A Java program will not compile unless it contains the correct line numbers.
Question
Assuming that pay has been declared a double, the following statement is valid.
pay = 2,583.44;
Question
This is a variable whose content is read only and cannot be changed during the program's execution.

A) operator
B) literal
C) named constant
D) reserved word
Question
Which of the following does not describe a valid comment in Java?

A) Single line comments, two forward slashes - //
B) Multi-line comments, start with /* and end with */
C) Multi-line comments, start with */ and end with /*
D) Documentation comments, any comments starting with /** and ending with */
Question
Which one of the following methods would you use to convert a string to a double?

A) Byte.ParseByte
B) Long.ParseLong
C) Integer.ParseInt
D) Double.ParseDouble
Question
If the compiler encounters a statement that uses a variable before the variable is declared, an error will result.
Question
Java is a case-insensitive language.
Question
Although the dollar sign is a legal identifier character, you should not use it because it is normally used for special purposes.
Question
What will be displayed as a result of executing the following code? int x = 8;
String msg = "I am enjoying java.";
String msg1 = msg.toUpperCase();
String msg2 = msg.toLowerCase();
Char ltr = msg.charAt(x);
Int strSize = msg.length();
System.out.println(msg);
System.out.println(msg1);
System.out.println(msg2);
System.out.println("Character at index x = " +
Ltr);
System.out.println("msg has " + strSize +
" characters.");

A) I am enjoying java.
I AM ENJOYING JAVA.
I am enjoying java.
Character at index x = j
Msg has 20 characters.
B) I am enjoying java.
I AM ENJOYING JAVA.
I am enjoying java.
Character at index x = o
Msg has 20 characters.
C) I am enjoying java.
I AM ENJOYING JAVA.
I am enjoying java.
Character at index x = o
Msg has 19 characters.
D) I am enjoying java.
I AM ENJOYING JAVA.
I am enjoying java.
Character at index x = y
Msg has 19 characters.
Question
What will be displayed after the following statements have been executed? final double x = 99.0;
X = 54.3;
System.out.println("x = " + x );

A) x = 54.3
B) x = 99
C) x = 153.3
D) Nothing, this is an error.
Question
Which of the following statements correctly creates a Scanner object for keyboard input?

A) Scanner kbd = new Scanner(System.keyboard);
B) Scanner keyboard(System.in);
C) Scanner keyboard = new Scanner(System.in);
D) Keyboard scanner = new Keyboard(System.in);
Question
Class names and key words are examples of variables.
Question
All Java statements end with semicolons.
Question
Named constants are initialized with a value, that value cannot be changed during the execution of the program.
Question
Which Scanner class method reads an int?

A) readInt()
B) nextInt()
C) getInt()
D) read_int()
Question
Programming style includes techniques for consistently putting spaces and indentation in a program so visual cues are created.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/61
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 2: Java Fundamentals
1
What will be displayed as a result of executing the following code? int x = 5, y = 20;
X += 32;
Y /= 4;
System.out.println("x = " + x + ", y = " + y);

A) x = 32, y = 4
B) x = 9, y = 52
C) x = 37, y = 5
D) x = 160, y = 80
C
2
In Java, ___________ must be declared before they can be used.

A) Variables
B) Literals
C) Key words
D) Comments
A
3
To compile a program named First, use the following command:

A) java First.java
B) javac First
C) javac First.java
D) compile First.javac
C
4
In Java, the beginning of a comment is marked with:

A) //
B) ""
C) ;
D) #
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
5
What would be printed out as a result of the following code? System.out.println("The quick brown fox" +
"jumped over the \n"
"slow moving hen.");

A) The quick brown fox jumped over the \nslow moving hen.
B) The quick brown fox jumped over the
Slow moving hen.
C) The quick brown fox
Jumped over the
Slow moving hen.
D) Nothing. This is an error.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
6
What is the result of the following expression? 10 + 5 * 3 - 20

A) -5
B) 5
C) 25
D) -50
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
7
Which of the following cannot be used as identifiers in Java?

A) Variable names
B) Class names
C) Key words
D) All of the above
E) None of the above
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
8
What is the result of the following expression? 25 / 4 + 4 * 10 % 3

A) 19
B) 5.25
C) 3
D) 7
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
9
When the + operator is used with strings, it is known as the:

A) Assignment operator
B) String concatenation operator
C) Addition operator
D) Combined assignment operator
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
10
The term ___________ typically refers to the device that displays console output.

A) Standard output device
B) Central processing unit
C) Secondary storage device
D) Liquid crystal display
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
11
Which of the following is valid?

A) float y;
Y = 54.9;
B) float y;
Double z;
Z = 934.21;
Y = z;
C) float w;
W = 1.0f;
D) float v;
V = 1.0;
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
12
This is a value that is written into the code of a program.

A) literal
B) assignment statement
C) variable
D) operator
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
13
The boolean data type may contain values in the following range of values

A) true or false
B) -128 to + 127
C) - 2,147,483,648 to +2,147,483,647
D) - 32,768 to +32,767
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
14
Which of the following is not a rule that must be followed when naming identifiers?

A) The first character must be one of the letters a-z, A-Z, and underscore or a dollar sign.
B) Identifiers can contain spaces.
C) Uppercase and lowercase characters are distinct.
D) After the first character, you may use the letters a-z, A-Z, the underscore, a dollar sign, or digits 0-9.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
15
Character literals are enclosed in _____; string literals are enclosed in _____.

A) single quotes; single quotes
B) double quotes; double quotes
C) single quotes; double quotes
D) double quotes; single quotes
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
16
Which one of the following would contain the translated Java byte code for a program named Demo?

A) Demo.java
B) Demo.code
C) Demo.class
D) Demo.byte
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
17
A Java program must have at least one of these:

A) Class definition
B) Variable
C) Comment
D) System.out.println(); statement
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
18
In Java, it is standard practice to capitalize the first letter of:

A) Class names
B) Variable names
C) Key words
D) Literals
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
19
If the following Java statements are executed, what will be displayed? System.out.println("The top three winners are\n");
System.out.print("Jody, the Giant\n");
System.out.print("Buffy, the Barbarian");
System.out.println("Adelle, the Alligator");

A) The top three winners are
Jody, the Giant
Buffy, the Barbarian
Adelle, the Alligator
B) The top three winners are
Jody, the Giant\nBuffy, the BarbarianAdelle, the Alligator
C) The top three winners are Jody, the Giant\nBuffy, the BarbarianAdelle, and the Albino
D) The top three winners are
Jody, the Giant
Buffy, the BarbarianAdelle, the Alligator
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
20
Which of the following is not a primitive data type?

A) short
B) long
C) float
D) String
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
21
Every Java application program must have

A) a class named MAIN
B) a method named main
C) comments
D) integer variables
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
22
What will be displayed as a result of executing the following code? int x = 6;
String msg = "I am enjoying this class.";
String msg1 = msg.toUpperCase();
String msg2 = msg.toLowerCase();
Char ltr = msg.charAt(x);
Int strSize = msg.length();
System.out.println(msg);
System.out.println(msg1);
System.out.println(msg2);
System.out.println("Character at index x = " +
Ltr);
System.out.println("msg has " + strSize +
"characters.");

A) I am enjoying this class.
I AM ENJOYING THIS CLASS.
I am enjoying this class.
Character at index x = e
Msg has 24 characters.
B) I am enjoying this class.
I AM ENJOYING THIS CLASS.
I am enjoying this class.
Character at index x = e
Msg has 25 characters.
C) I am enjoying this class.
I AM ENJOYING THIS CLASS.
I am enjoying this class.
Character at index x = n
Msg has 24 characters.
D) I am enjoying this class.
I AM ENJOYING THIS CLASS.
I am enjoying this class.
Character at index x = n
Msg has 25characters.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
23
What is the result of the following expression? 17 % 3 * 2 - 12 + 15

A) 7
B) 8
C) 12
D) 105
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
24
The primitive data types only allow a(n) _____ to hold a single value.

A) variable
B) object
C) class
D) literal
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
25
What will be displayed as a result of executing the following code? public class test
{
Public static void main(String[] args)
{
Int value1 = 9;
System.out.println(value1);
Int value2 = 45;
System.out.println(value2);
System.out.println(value3);
Value = 16;
}
}

A) 9
45
16
B) 94516
C) 9 45 16
D) Nothing, this is an error
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
26
What is the result of the following expression? 25 - 7 * 3 + 12 / 3

A) 6
B) 8
C) 10
D) 12
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
27
If x has been declared an int, which of the following statements is invalid?

A) x = 0;
B) x = -58932;
C) x = 1,000;
D) x = 592;
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
28
Variables of the boolean data type are useful for

A) working with small integers
B) evaluating true/false conditions
C) working with very large integers
D) evaluating scientific notation
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
29
To display the output on the next line, you can use the println method or use this escape sequence in the print method.

A) \n
B) \r
C) \t
D) \b
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
30
What would be displayed as a result of the following code? int x = 578;
System.out.print("There are " +
X + 5 + "\n" +
"hens in the hen house.");

A) There are 583 hens in the hen house.
B) There are 5785 hens in the hen house.
C) There are x5\nhens in the hen house.
D) There are 5785
Hens in the hen house.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
31
What will be displayed after the following statements have been executed? int x = 15, y = 20, z = 32;
X += 12;
Y /= 6;
Z -= 14;
System.out.println("x = " + x +
", y = " + y +
", z = " +z);

A) x = 27, y = 3.333, z = 18
B) x = 27, y = 2, z = 18
C) x = 27, y = 3, z = 18
D) x = 37, y = 14, z = 4
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
32
This is a named storage location in the computer's memory.

A) Literal
B) Constant
C) Variable
D) Operator
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
33
What will be the displayed when the following code is executed? final int x = 22, y = 4;
Y += x;
System.out.println("x = " + x +
", y = " + y);

A) x = 22, y = 4
B) x = 22, y = 26
C) x = 22, y = 88
D) Nothing, this is an error
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
34
Which of the following is not a valid comment statement?

A) // comment 1
B) /* comment 2 */
C) */ comment 3 /*
D) /** comment 4 */
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
35
Variables are classified according to their

A) value
B) data type
C) names
D) location in the program
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
36
In the following Java statement what value is stored in the variable name? String name = "John Doe";

A) John Doe
B) The memory address where "John Doe" is located
C) name
D) The memory address where name is located
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
37
What will be the value of z as a result of executing the following code? int x = 5, y = 28;
Float z;
Z = (float) (y / x);

A) 5.60
B) 5.6
C) 3.0
D) 5.0
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
38
What will be the value of z after the following statements have been executed? int x = 4, y = 33;
Double z;
Z = (double) (y / x);

A) 8.25
B) 4
C) 8
D) 8.0
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
39
To print "Hello, world" on the monitor, use the following Java statement

A) SystemOutPrintln("Hello, world");
B) System.out.println{"Hello, world"}
C) System.out.println("Hello, world");
D) Print "Hello, world";
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
40
Given the declaration double r;, which of the following statements is invalid?

A) r = 326.75;
B) r = 9.4632e15;
C) r = 9.4632E15;
D) r = 2.9X106;
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
41
Both character literals and string literals can be assigned to a char variable.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
42
In Java the variable named total is the same as the variable named Total.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
43
Which of the following is a valid Java statement?

A) String str = 'John Doe';
B) string str = "John Doe";
C) string str = 'John Doe';
D) String str = "John Doe";
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
44
A variable's scope is the part of the program that has access to the variable.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
45
Which Scanner class method reads a String?

A) readString()
B) nextString()
C) getString()
D) nextLine()
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
46
A Java program will not compile unless it contains the correct line numbers.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
47
Assuming that pay has been declared a double, the following statement is valid.
pay = 2,583.44;
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
48
This is a variable whose content is read only and cannot be changed during the program's execution.

A) operator
B) literal
C) named constant
D) reserved word
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
49
Which of the following does not describe a valid comment in Java?

A) Single line comments, two forward slashes - //
B) Multi-line comments, start with /* and end with */
C) Multi-line comments, start with */ and end with /*
D) Documentation comments, any comments starting with /** and ending with */
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
50
Which one of the following methods would you use to convert a string to a double?

A) Byte.ParseByte
B) Long.ParseLong
C) Integer.ParseInt
D) Double.ParseDouble
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
51
If the compiler encounters a statement that uses a variable before the variable is declared, an error will result.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
52
Java is a case-insensitive language.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
53
Although the dollar sign is a legal identifier character, you should not use it because it is normally used for special purposes.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
54
What will be displayed as a result of executing the following code? int x = 8;
String msg = "I am enjoying java.";
String msg1 = msg.toUpperCase();
String msg2 = msg.toLowerCase();
Char ltr = msg.charAt(x);
Int strSize = msg.length();
System.out.println(msg);
System.out.println(msg1);
System.out.println(msg2);
System.out.println("Character at index x = " +
Ltr);
System.out.println("msg has " + strSize +
" characters.");

A) I am enjoying java.
I AM ENJOYING JAVA.
I am enjoying java.
Character at index x = j
Msg has 20 characters.
B) I am enjoying java.
I AM ENJOYING JAVA.
I am enjoying java.
Character at index x = o
Msg has 20 characters.
C) I am enjoying java.
I AM ENJOYING JAVA.
I am enjoying java.
Character at index x = o
Msg has 19 characters.
D) I am enjoying java.
I AM ENJOYING JAVA.
I am enjoying java.
Character at index x = y
Msg has 19 characters.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
55
What will be displayed after the following statements have been executed? final double x = 99.0;
X = 54.3;
System.out.println("x = " + x );

A) x = 54.3
B) x = 99
C) x = 153.3
D) Nothing, this is an error.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
56
Which of the following statements correctly creates a Scanner object for keyboard input?

A) Scanner kbd = new Scanner(System.keyboard);
B) Scanner keyboard(System.in);
C) Scanner keyboard = new Scanner(System.in);
D) Keyboard scanner = new Keyboard(System.in);
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
57
Class names and key words are examples of variables.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
58
All Java statements end with semicolons.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
59
Named constants are initialized with a value, that value cannot be changed during the execution of the program.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
60
Which Scanner class method reads an int?

A) readInt()
B) nextInt()
C) getInt()
D) read_int()
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
61
Programming style includes techniques for consistently putting spaces and indentation in a program so visual cues are created.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 61 flashcards in this deck.