Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

54.Java literals

Total questions: 47

Worksheet time: 24mins

Name
Class
Date
1.
What are the 5 literals in Java?
a)
Boolean, integer, character, string, and floating-point literals.
b)
Integer, character, Boolean, and null literals.
c)
Integral, floating-point, char, string, and boolean literals.
d)
Exact numeric, approximate numeric, character, string, and boolean literals.
2.
What are the 3 literals in Java?
a)
Integer Literal, Character Literal, Boolean Literal.
b)
Floating-point Literal, String Literal, Null Literal.
c)
Integral Literal, Char Literal, Boolean Literal.
d)
Exact Numeric Literal, Approximate Numeric Literal, Character Literal.
3.
What are the different types of Java literals?
a)
Integral, Floating-point, Char, String, Boolean, and Null Literals.
b)
Numeric, Character, and Boolean Literals.
c)
Integer, Decimal, and Date Literals.
d)
Primitive, Reference, and Null Literals.
4.
What is an example of a number literal in Java?
a)
65,–233, and +12.
b)
57.,–85.7, and +2.1.
c)
'a', '7', '$', 'π'.
d)
"Hello", "world", "123".
5.
What is literals and types?
a)
Literals represent fixed values in the code, while types specify the data represented by the variable.
b)
Literals are variables, and types are constants.
c)
Literals and types are the same concepts in Java.
d)
Literals and types both represent variable values.
6.
What is literals in Java symbol?
a)
Double quotes (").
b)
Single quotes (').
c)
Backticks ( ` ).
d)
Square brackets ( [] ).
7.
Is string a literal in Java?
a)
Yes, a string literal is a constant value represented by double quotes.
b)
No, a string literal can be represented by single quotes or double quotes interchangeably.
c)
Yes, a string literal always refers to a new instance of the String class.
d)
No, string literals can only contain characters, not numbers or special characters.
8.
What are the 3 types of literals in SQL?
a)
String, Numeric, Date literals.
b)
Integer, Floating-point, Character literals.
c)
Numeric, Boolean, Null literals.
d)
String, Boolean, Date and Time literals.
9.
What is a literal data type?
a)
A data type that can change its value during program execution.
b)
A data type used only for literals and not variables.
c)
A value expressed as itself rather than a variable's value.
d)
A data type used exclusively for floating-point numbers.
10.
How many literals are there?
a)
3
b)
4
c)
6
d)
6
11.
What are the four types of integer literals?
a)
Decimal integer literals, Hexadecimal integer literals, Octal integer literals, Binary integer literals.
b)
Whole number literals, Fractional number literals, Exponential number literals, Complex number literals.
c)
Positive integer literals, Negative integer literals, Zero integer literals, Infinite integer literals.
d)
Integral integer literals, Decimal integer literals, Binary integer literals, Octal integer literals.
12.
What do you mean by literals?
a)
Constants that change their value during program execution.
b)
Values represented as variables in Java code.
c)
Conventional forms of values that cannot be modified.
d)
Variables that have constant values throughout the program.
13.
What are non literals in Java?
a)
Variables whose values cannot be changed.
b)
Constants represented by fixed values.
c)
Objects created using the 'new' keyword.
d)
Literal values that are not directly used in the code.
14.
What are literals? Give any two examples.
a)
Constants with references as variables, e.g., 10 and "Hello".
b)
Values that change during program execution, e.g., 3.14 and "world".
c)
Values written in conventional form whose value is obvious, e.g., 123 and 4.3.
d)
Variables that can be modified, e.g., const int = 10; and new Object();.
15.
What is the difference between a literal and a variable in Java?
a)
Literals are constants, while variables can change their value.
b)
Variables are constants, while literals represent changing values.
c)
Literals use double quotes, and variables use single quotes.
d)
Variables are immutable, while literals are mutable.
16.
What are the 5 major literal types in Java?
a)
Boolean, character, integer, string, and floating-point literals.
b)
Integer, character, boolean, and null literals.
c)
Exact numeric, approximate numeric, character, string, and boolean literals.
d)
Integral, floating-point, char, string, and null literals.
17.
What is the literal of 0.5 in Java?
a)
0.5d
b)
0.5f
c)
0x1p-1f
d)
0.5
18.
What are Java keywords?
a)
Terms reserved for special functions in the Java programming language.
b)
Identifiers for program elements like classes, variables, and methods.
c)
Reserved terms that cannot be used as identifiers for any program elements.
d)
Special characters used in Java programming.
19.
What is data type in Java?
a)
Primitive and Non-primitive data types.
b)
Integer, Float, String, and Boolean data types.
c)
Classes and Methods data types.
d)
Reserved terms used for variable declaration.
20.
How are literals stored in Java?
a)
In the Java Heap memory.
b)
In the String Pool or String Constant Pool.
c)
In the Java Stack memory.
d)
In the Java Virtual Machine.
21.
What is a variable in Java?
a)
A container for storing data values.
b)
A keyword used to define classes.
c)
A fixed number of values of the same type.
d)
A reference to an instance of a class.
22.
What is an array in Java?
a)
A container for storing multiple data values of different types.
b)
A fixed number of values of different types.
c)
A reserved term used for conditional statements.
d)
A container for holding a fixed number of values of a single type.
23.
What is a thread in Java?
a)
A reserved term used for creating loops.
b)
A container for holding multiple classes.
c)
A sequence of characters in a source code.
d)
A thread of execution in a program that can run concurrently with other threads.
24.
What is a literal string called?
a)
Character string
b)
Text string
c)
String constant
d)
String literal
25.
What are the two boolean literals?
a)
true and false
b)
yes and no
c)
on and off
d)
positive and negative
26.
What are the two numeric literals?
a)
float and double
b)
real and imaginary
c)
integer and fractional
d)
positive and negative
27.
What are the 3 literals in Python?
a)
Numeric Literals, String Literals, Boolean Literals
b)
Integer Literals, Floating-point Literals, Character Literals
c)
String Literals, Array Literals, Null Literals
d)
True Literal, False Literal, None Literal
28.
Is a boolean a literal?
a)
Yes, a boolean literal is a character-string delimited by B" and ".
b)
No, a boolean literal is only represented by the characters 0 or 1.
c)
Yes, a boolean literal represents the value of a variable.
d)
No, a boolean literal is not a valid concept in programming.
29.
What is literal syntax?
a)
Shorthand notation for values in certain types.
b)
Syntax used to represent literal values in mathematical expressions.
c)
The representation of strings using special characters.
d)
The syntax used for defining new data types in Java.
30.
What is an example of a literal?
a)
"The quick brown fox jumps over the lazy dog."
b)
The heavy rain caused flooding in the city.
c)
x = 5 + y
d)
The sun rises in the east.
31.
What values are literals?
a)
Variables and Lingo elements.
b)
Character strings, integers, decimal numbers, and constants.
c)
Reserved terms and special characters.
d)
String, Integer, Float, and Boolean data types.
32.
What are the rules of literals?
a)
Two literals are identical if they contain a location counter reference.
b)
Two literals are identical if their source forms are different.
c)
Two literals are identical if their source forms are identical.
d)
Two literals are identical if they are generated more than once.
33.
What is the long literal in Java?
a)
A 64-bit floating-point number.
b)
A 64-bit two's complement integer.
c)
A 32-bit floating-point number.
d)
A 32-bit two's complement integer.
34.
What is literal number?
a)
The representation of a real number in exponential notation.
b)
The representation of a real number in binary format.
c)
The representation of a real number in base-10 integer form.
d)
The representation of a real number in fixed-point decimal notation.
35.
What is a decimal literal?
a)
A numeric value with a decimal point, without fractional or exponential parts.
b)
A numeric value in binary format.
c)
A numeric value represented in exponential notation.
d)
A numeric value without any decimal point.
36.
What is the difference between character and string literal?
a)
Character literals are enclosed in double quotes, and string literals in single quotes.
b)
Character literals are written in uppercase, and string literals in lowercase.
c)
Character literals are enclosed in single quotes, and string literals in double quotes.
d)
Character literals have a fixed length, while string literals have varying lengths.
37.
What is literal in function?
a)
A named memory location that stores a reference to a function.
b)
An expression that defines an unnamed function.
c)
A fixed value or data used in a function.
d)
A type of function used for literals.
38.
What is the opposite of literal?
a)
Figuratively
b)
Truthfully
c)
Hypothetically
d)
Literally
39.
What is literal in binary?
a)
Binary literals are written as a sequence of characters within double quotes.
b)
Binary literals are written as a sequence of characters within single quotes.
c)
Binary literals are written in the format 'b'value', e.g., b'1010'.
d)
Binary literals are written in the format '0bvalue', e.g., 0b1010.
40.
Why is a string immutable in Java?
a)
Strings in Java are cached by the JVM to improve performance.
b)
Strings in Java are designed to be easily changed during runtime.
c)
Strings in Java share storage to minimize redundant copies.
d)
Strings in Java cannot be changed once created.
41.
What are integer literals in Java?
a)
Numeric values with fractional parts.
b)
Numeric values with exponential parts.
c)
Numeric values without fractional or exponential parts.
d)
Numeric values represented in binary format.
42.
What are constants in Java?
a)
Variables whose values can change during runtime.
b)
Reserved words in Java used for defining data types.
c)
Variables whose values cannot be changed once assigned.
d)
Built-in functions in Java for mathematical calculations.
43.
What is the difference between a variable and a literal?
a)
Variables are fixed values, and literals can change during runtime.
b)
Variables store references to literals.
c)
Variables are raw values, and literals are named memory locations.
d)
Variables are mutable, and literals are immutable.
44.
Is a string variable literal?
a)
Yes, a string variable is a fixed value stored in memory.
b)
No, a string variable is a named memory location that can change during runtime.
c)
Yes, a string variable represents a sequence of characters.
d)
No, a string variable cannot be directly written in code.
45.
What is the difference between character and boolean literal in Java?
a)
A character literal stores true or false values, while a boolean literal stores characters.
b)
A character literal stores a single character, while a boolean literal stores a boolean value (true or false).
c)
A character literal is written in binary format, while a boolean literal is written in decimal format.
d)
A character literal is enclosed in double quotes, while a boolean literal is enclosed in single quotes.
46.
Is a literal a type of variable?
a)
Yes, literals are variables that store fixed values.
b)
No, literals are fixed values, not variables.
c)
Yes, literals are variables with named memory locations.
d)
No, literals are only used for mathematical calculations.
47.
What do literals represent in JavaScript?
a)
Fixed values used for data storage.
b)
Variables with named memory locations.
c)
Mathematical functions.
d)
Expressions used to define functions.