1.
The line of Java code below has the last character missed.int lastOne = 3The missed character is:
Correct Answer
D. ;
Explanation
The missed character in the line of Java code is ";". This is because the line of code is declaring a variable named "lastOne" and assigning it a value of 3. In Java, it is necessary to end statements with a semicolon (;) to indicate the end of the line of code.
2.
The text below is a fragment of a Java code. public class Random {public static void main(String[] args) {int rMath = Math.random()*100 == This code should be saved as:
Correct Answer
C. Random.java
Explanation
The code is defining a class named "Random" and declaring a main method within it. The main method initializes an integer variable called "rMath" and assigns the result of the expression "Math.random()*100" to it. The double value returned by Math.random() is multiplied by 100 and then compared to 0. Since the result of this comparison is a boolean value, it cannot be assigned to the integer variable "rMath" as it expects an integer value. Therefore, the code has an error and should be saved as "Random.java".
3.
According to the Java program code fragment below,public class Random {
public static void main(String[] args) {
int rMath = Math.random()*100 == int rMath means:
Correct Answer
B. RMath is a variable and its value is an integer
Explanation
The code fragment declares a variable named rMath, indicating that rMath is a variable. Additionally, the code assigns the result of the expression Math.random()*100 to rMath, which implies that its value is an integer.
4.
The following line of a Java code:System.out.println("The number = " + num);makes the computer to:
Correct Answer
B. Print a new line "The number = " and then the value of the variable "num".
Explanation
The given line of code, System.out.println("The number = " + num), will print a new line "The number = " followed by the value of the variable "num". The "+" operator is used to concatenate the string "The number = " with the value of the variable "num", resulting in the desired output.
5.
For the code line: System.out.println("The number = " + num); and the code line:System.out.print("The number = " + num);,the following is true:
Correct Answer
C. The first one makes the continuation of the text/information to be printed on the next line. The second does not, so that the new information would be printed on the same line.
Explanation
The first code line, System.out.println("The number = " + num);, prints the text "The number =" followed by the value of the variable "num" on the next line. The second code line, System.out.print("The number = " + num);, prints the same text and value, but without moving to the next line. Therefore, the first code line makes the continuation of the text/information to be printed on the next line, while the second code line does not.
6.
The line: tenPercentTax = 0.10*(netIncome - 30000);means:
Correct Answer
A. The value of the variable "tenPercentTax" equals to the result of (netIncome - 30000) times 0.10
Explanation
The correct answer is the value of the variable "tenPercentTax" equals to the result of (netIncome - 30000) times 0.10. This means that the variable "tenPercentTax" is calculated by subtracting 30000 from the net income and then multiplying that result by 0.10, which represents 10% in decimal form. This calculation allows for the determination of the ten percent tax based on the net income.
7.
The word "double" in the following Java code line:double sum =means that
Correct Answer
B. The memory space for the variable "sum" will be twice more than a regular one.
Explanation
The word "double" in the given Java code line indicates that the memory space for the variable "sum" will be twice as large as a regular variable. In Java, the "double" data type is used to represent decimal numbers with double precision, which requires more memory compared to regular data types like "int" or "float". Therefore, using "double" for the variable "sum" implies that it can store larger decimal values with higher precision.
8.
In Java code, The following line:String name = "Student";actually means:
Correct Answer
D. "name" is a text variable and its value is the word "Student"
Explanation
The given correct answer for this question is "name" is a text variable and its value is the word "Student". This is because the line of code "String name = "Student";" declares a variable named "name" of type String and assigns it the value "Student".
9.
A Java class code ends with:
Correct Answer
A. }
Explanation
In Java, a class code ends with a closing curly brace (}). This is because the opening curly brace ({) denotes the start of the class code block, and the closing curly brace marks the end of the code block. It is important to have a balanced number of opening and closing curly braces to ensure that the code is syntactically correct. The other options, such as ), ] and (), are not used to end a class code in Java.
10.
An integer is:
Correct Answer
C. Any whole number (includes positive, negative, and zero)
Explanation
The correct answer is any whole number (includes positive, negative, and zero). This is because an integer is defined as a number that does not have a fractional or decimal part. It can be positive, negative, or zero, and it includes all whole numbers.