問題一覧
1
Stores whole numbers, positive or negative (such as 123 or -456), without decimals. Valid types are byte, short, int and long. Which type you should use, depends on the numeric value.
Integer types
2
is a statement that can convey a value. Some of the most common are mathematical, such as in the following source code example: int number = 4; int anotherNumber = number; int product = number * anotherNumber;
Expressions
3
Name The variable name must follow rules for identifiers.
True
4
can store whole numbers from -32,768 to 32,767.
Short
5
this line of code correct? System.out.println("The area is " + String.format(%.2f, area) + ".");
False
6
The “precision of float” is only six(6) or seven(7) decimal digits, while “double variables” have a precision of about “15 digits”. Therefore it is safer to use double for most calculations.
True
7
Identifiers cannot use Java keywords like class, public, void, etc.
True
8
type is used to store a single character. The character must be surrounded by single quotes, like 'A' or 'c':
Character
9
can store whole numbers from -2,147,483,648 to 2,147,483,647. In general, the int data type is the preferred data type when we create variables with a numeric value.
Int
10
Java Identifiers Best Practices: For names of methods and variables
anExampleOfMethodName
11
used to check the relationship between two operands.
Relational operators
12
Is this a valid variable name? _option
True
13
Examples of non-primitive types are Strings, Arrays, Classes, Interface, etc.
True
14
can store fractional numbers from 1.7e−308 to 1.7e+308.
Double
15
Is this a best practice and recommended code for declaration? int inputNumber;
True
16
Data types are divided into two groups: Primitive data types Non-primitive data types
True
17
Identifiers can be short names (like x and y) or more descriptive names (age, sum, totalVolume). It is recommended to use descriptive names in order to create understandable and maintainable code.
True
18
There are no errors in this code snippet. if(age >= 18) { System.out.print("Adult"); } else { System.out.print("Minor"); }
True
19
Solve the expression, is the answer correct? double number; number = 20 / 2 * 4 - 2 + 10 - (-2); System.out.println(number); 50
False
20
Java Identifiers Best Practices: For names of constant
EXAMPLE_OF_A_CONSTANT
21
Is this line of code correct? System.out.println("I love Java\nprogramming.\n");
true
22
int answer; answer = 30 - 20 / 10 / 3 + 100 / 2; System.out.println(answer); The answer is 80.
True
23
type is used to store a sequence of characters (text). String values must be surrounded by double quotes.
Strings
24
type can store whole numbers from 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. This is used when int is not large enough to store the value.
Long
25
The general rules for constructing names for an identifier (unique identifiers) are: Identifiers must begin with either a letter, an underscore “_”, or a dollar sign “$”. Letters may be lower or upper case. Subsequent characters may use numbers 0 to 9.
True
26
are used to check whether an expression is true or false. If the expression is true, it returns 1 whereas if the expression is false, it returns 0.
Logical Operators
27
Is this line of code correct? public Static void main(String[] args) { }
False
28
Is this line of code correct? if(console.hasNextDouble() == true):
False
29
Solve the expression, is the answer correct? int number; number = 10 - 4 + 8 / 4 * 2; System.out.println(number); The answer is 10.
true
30
Represents numbers with a fractional part, containing one or more decimals.
Floating point Type
31
types are called reference types because they refer to objects.
Non - Primitive Data Types
32
What are the two tyoes of floating data types:
Float & double
33
is an item of data used to store the state of objects.
Variable
34
double answer; answer = 12 - 20 / 4 + 10 % 2 + 6 % 2 - 1; System.out.println(answer); The answer is 6.0double answer; answer = 12 - 20 / 4 + 10 % 2 + 6 % 2 - 1; System.out.println(answer); The answer is 6.0
True
35
can store fractional numbers from 3.4e−038 to 3.4e+038.
Float
36
Solve this expression, is the answer correct? int answer; answer = 50 * 2 - 15 / 3 + 10 % 2 + 6; System.out.print(answer); The answer is 101.
True
37
Java Identifiers Best Practices For names of classes
AnExampleOfClassName
38
can store whole numbers from -128 to 127. This can be used instead of int or other integer types to save memory when you are certain that the value will be within -128 and 127.
Byte
39
are used to perform common mathematical operations.
Arithmetic operators
40
Is this a best practice and recommended code for declaration of variable? int secondInput;
True
41
Avoid using underscores at the start of the identifier such as _read or _write.
true
42
Solve this expression, is the answer correct? int answer; answer = 40 - 10 / 5 * 6 / 3 + 100 / 2; System.out.print(answer); The answer is 76.
False
43
type is declared with the boolean keyword and can only take the values true or false.
Boolean
44
are used with only one operand.
Unary Operators
45
are used to assign values to variables.
Assignment Operators
46
Is this line of code correct? length = input.nextFloat();
True
47
Solve the expression, is the answer correct? double number; number = 40 - 10 / 5 * 6 / 3 + 100 / 2; System.out.println(number); The answer is 86.
False
48
specifies the size and type of variable values, and it has no additional methods.
Primitive Data Type
49
Is this a best practice and recommended code for a class name? PrimeNumbers
True
50
Solve the expression, is the answer correct? double number; number = 50 + 10 / 5 * 6 / 2 + 100; System.out.println(number); The answer is 156.0
True
51
are tokens that represent names of variables, methods, classes, and other user-defined program elements. All Java variables must be identified with unique names.
Identifiers
52
is an attribute of data which tells the compiler or interpreter how the programmer intends to use the data.
Data Type
53
is a symbol that tells the compiler to perform specific mathematical or logical manipulations. Java is rich in built-in operators and provide the following types of operators: 1. Unary Operators 2. Arithmetic operators 3. Assignment operators 4. Relational operators 5. Logical operators
Operators
54
Is this a valid variable name? number1
true
55
determines the type of value that the variable can hold.
Data Type