# Java Online Quiz 2

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
| By TeacheMeIDEA
T
TeacheMeIDEA
Community Contributor
Quizzes Created: 6 | Total Attempts: 15,410
Questions: 10 | Attempts: 412  Settings  .

• 1.

### Which of these literals can be contained in a data type float variable ?

• A.

1.7e-308

• B.

3.4e-038

• C.

1.7e+308

• D.

3.4e-050

B. 3.4e-038
Explanation
The given correct answer, 3.4e-038, can be contained in a data type float variable because it is within the range of values that a float variable can hold. The "e-038" represents the exponent, indicating that the number is multiplied by 10 raised to the power of -38. This notation is commonly used in scientific notation to represent very small numbers. Since a float variable can store numbers with a range of approximately -3.4e38 to 3.4e38, 3.4e-038 falls within this range and can be stored in a float variable.

Rate this question:

• 2.

### Which data type value is returned by all transcendental math functions ?

• A.

Int

• B.

Float

• C.

Double

• D.

Long

C. Double
Explanation
Transcendental math functions, such as sin, cos, and exp, deal with mathematical operations that involve irrational numbers and constants like π and e. These functions require a high level of precision and accuracy, which is why they typically return values of type double. The double data type in programming languages provides a larger range and higher precision compared to float or int, making it suitable for handling the complex calculations involved in transcendental math functions.

Rate this question:

• 3.

### Which of the following coding types is used for the data type characters in Java ?

• A.

ISO-LATIN-1

• B.

UNICODE

• C.

ASCII

• D.

None of the above

B. UNICODE
Explanation
UNICODE is the coding type used for the data type characters in Java. UNICODE is a universal character encoding standard that supports characters from all languages and scripts. It provides a unique code point for each character, allowing for the representation of a wide range of characters and symbols. This makes it suitable for handling characters in different languages and ensures compatibility across different platforms and systems. ISO-LATIN-1 and ASCII are specific character encoding standards that do not cover the full range of characters supported by UNICODE. Therefore, the correct answer is UNICODE.

Rate this question:

• 4.

### Which of the following values, a boolean variable can contain ?

• A.

True and False

• B.

Any integer value

• C.

0 and 1

• D.

None of the above

A. True and False
Explanation
A boolean variable can only contain two values, which are True and False. These values represent the logical states of true and false, respectively. Any other value, such as an integer or 0 and 1, cannot be assigned to a boolean variable as it can only hold these two specific values.

Rate this question:

• 5.

### Which of the following is a correct declaration of variable in Java ?

• A.

Int num

• B.

Int-num

• C.

Int num;

• D.

Int-num;

C. Int num;
Explanation
The correct declaration of a variable in Java is "int num;". In Java, variable declarations follow the syntax of specifying the data type (in this case, "int" for integer) followed by the variable name (in this case, "num") and ending with a semicolon. The other options provided ("int-num", "int num;", "int-num;") are not valid declarations as they either include invalid characters or have incorrect syntax.

Rate this question:

• 6.

### Which of the following is a correct variable initialization in Java ?

• A.

Int num = 10

• B.

Int-num = 10

• C.

Int num = 10;

• D.

Int-num = 10

C. Int num = 10;
Explanation
The correct variable initialization in Java is "int num = 10;". In Java, when declaring and initializing a variable, the syntax is to first specify the data type (in this case, "int" for integer), followed by the variable name (in this case, "num"), and then the assignment operator "=" to assign a value to the variable (in this case, 10). The semicolon at the end indicates the end of the statement. The other options are incorrect because they either use an invalid variable name (containing a hyphen) or do not include the assignment operator.

Rate this question:

• 7.

### What is the default value of the data type byte in Java ?

• A.

0

• B.

Null

• C.

1

• D.

None of the above

A. 0
Explanation
The default value of the data type byte in Java is 0.

Rate this question:

• 8.

### What is the default value of the data type int in Java ?

• A.

1

• B.

0

• C.

0i

• D.

None of the above

B. 0
Explanation
The default value of the data type int in Java is 0.

Rate this question:

• 9.

### What is the default value of the data type long in Java ?

• A.

0

• B.

1

• C.

0L

• D.

10

C. 0L
Explanation
The default value of the data type long in Java is 0L. In Java, when a variable of type long is declared but not initialized, it is automatically assigned the value of 0L by default. The "L" at the end of the value indicates that it is a long literal.

Rate this question:

• 10.

### What is the default value of the data type double in Java ?

• A.

0

• B.

1

• C.

0.0D

• D.

0.0

C. 0.0D
Explanation
The default value of the data type double in Java is 0.0D. In Java, when a variable of type double is declared but not initialized, it is automatically assigned the value of 0.0D. The "D" at the end of the value indicates that it is a double type literal.

Rate this question:

Related Topics Back to top