(2-3) Flashcards
(76 cards)
What will be displayed after the following statements have been executed?
Final double x;
x = 54.3;
System.out.println(“x = “ + x);
Nothing, it’s an error
What is a result of the following expression?
10 + 5 * 3 - 20
5
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;
}
}
Nothing, it’s an error
To compile a program named First, use the following command
javac First.java
Which of the following is a valid Java statement?
String str = “John Doe.”;
Which of the following is NOT a primitive data type?
String
Given the declaration double r; which of the following statements is invalid?
r = 2.9X106;
Which of the following is NOT a rule that must be followed when naming identifiers?
Identifiers can contain spaces
To display the output on the next line, you can use the println method or use this escape sequence in the print method:
\n
When saving a Java source file save it with an extension of:
.java
This is a variable whose content is read only and cannot be changed during the program’s execution:
Named constant
A variable’s scope is the part of the program that has access to the variable
True
The boolean data type may contain values in the following range of values:
True or false
A java program must have at least one of these:
Class definition
In the following Java statement what value is stored in the variable name?
Str = “John Doe”;
The memory address where “John Doe” is located
When the + operator is used with strings, it is known as:
String concatenation operator
If x has been declared as an int, which of the following statements is invalid?
x = 1,000;
In Java, it’s standard practice to capitalize the first letter of:
Class names
Which Scanner class reads an int?
nextInt()
If the compiler encounters a statement that uses a variable before the variable is declared an error will occur.
True
Variables are classified according to their:
Data type
This is a value that is written into the code of the program
Literal
What is the result of the following code?
25 - 7 * 3 + 12 / 3
8
In Java, the beginning of a comment is marked with:
//