Font size
Worksheets22BCA6A-Java-Quiz1
Total questions: 100
Worksheet time: 1hrs 18mins
It is used to store two types of values, i.e., true or false. This data type is commonly used as a flag in code logic.
boolean
byte
char
String
It can store 8-bit signed two’s complement integer. The range lies between -128 to 127
byte
boolean
char
string
This data type is used to store a single 16-bit Unicode character. It stores just one character in simple words, and the word Unicode is used because java uses the Unicode system, not the ASCII system. The size of this data type is 16bits (2 bytes).
byte
boolean
char
int
It is a data type that stores 32 bit(4 bytes) two’s complement integer, i.e., its range lies within (-2^31 to 2^32 – 1).
int
float
double
String
Similar to ‘int,’ it is also used to store integer values but within 16-bit (2 bytes) signed two’s complement. Its range lies within (-2^15 to 2^16-1).
int
long
short
byte
It is 64 bit two’s complement integer and its range lies within (-2^63 to2^64 – 1) i.e. ( -9,223,372,036,854,775,808 to 9,223,372,036,854,775,808).
int
short
long
byte
It is a data type that holds data with more precision, i.e., floating-point numbers. It is a single-precision 32-bit (4 bytes) IEEE754 floating-point.
int
float
double
char
It is a double-precision 64-bit (8 bytes) IEEE754 floating point.
float
double
long
int
It is a sequence of characters.
char
string
boolean
int
An element of a program that defines the type of data that a variable will hold
variable
expression
operator
data type
Which of these is long data type literal?
0x99fffL
ABCDEFG
0x99fffa
99671246
System.out.println("one\rtwo");
two
onetwo
one\rtwo
twoone
System.out.println("one\btwo");
one two
onetwo
one
two
ontwo
System.out.println("\"Java Program\"");
(a)
System.out.println("b="+0b101);
(a)
How many primitive data types are there in java?
(a)
Which is the smallest integer datatype in java?
byte
int
small
smallint
Choose valid identifier
a_101$100
100$a
/a_123
(a100)
How will you declare a boolean data type
boolean b;
bool b;
Long is 4 byte size in storage?
True
False
char is 2 byte in storage?
True
False
(=) sign means
equals and it is used for math problems in Java
assignment operator. It used to assign a value
Which one is used for remainder in Java?
/
%
+
*
int x = 3; in this case, which of the following statement is true?
x = x+1;
x++;
x += 1;
All of above
A developer wants to convert a smaller data type to larger data type. What is this in Java?
Widening primitive
Narrowing primitive
Which of the following is NOT safe and can result in a loss of data?
Narrowing primitive
Widening primitive
This data type returns true or false
String
boolean
char
int
Name the data type: 1.0
double
int
char
boolean
Name the data type: "true"
boolean
char
String
double
Name the data type: '3'
int
char
String
None of the above
Which expression evaluates to true?
false == false
true != true
4 < 4
true == true != true
Which expression evaluates to false?
15 % 3 < 2
3 * 3 % 2 <= 0
false == false
false == false == false == false
Which declaration will throw an error?
String name = "1 1233 141";
double num = 1;
int bigNumber = 1234567890;
char random = '7';
Which declaration will throw an error?
double num = 8;
int averageGrade = 89.7;
boolean done = false;
String done = "true";
Which of the following is a primitive data type?
double
Integer
String
List
Number
int x;
/* What is the correct description of the code segment? */
The variable x has been declared as an int.
The variable x has been initialized as an int.
The variable x has been instantiated as an int.
The variable x has been referenced as an int.
Which best describes primitive data types in Java?
Primitive data types point to an object.
Primitive data types are rarely used in Java.
String is a primitive data type.
Primitive data types are the most basic building blocks of all code generated in Java.
Primitive data types are data types used by cave people to write code.
Java Tokens help the compiler. Which of the following is a type of Java Token?
Identifiers
Keywords
Operators
All of the answers.
15
5
Compiler error
Runtime error
15
5
Compiler error
Runtime error
15
5
Compiler error
Runtime error
15
5
Compiler error
Runtime error
15
5
Compiler error
Runtime error
15
5
Compiler error
Runtime error
15
5
15.0
5.0
true
false
Compiler error
Runtime error
11
12
Compiler error
Runtime error
11.0
12.0
11
12
false
true
Compiler error
Runtime error
11
9
11
10
10
9
9
8
12
11
11
11
10
11
11
12
11
12
10
13
11
12
10
13
11
12
10
Compiler error
11
12
10
Compiler error
-11
9
10
-10
10.0
-10.0
Compiler error
200
190
101
0.5
220
210
1000
0
220
210
1000
0
2
80
Compiler error
20
5
5
5
10
10
10
10
5
true
false
Runtime error
Compiler error
10
No output
Compiler error
Runtime error
a
b
Compiler error
-1
a
b
Compiler error
-1
true
false
Compiler error
Runtime error
true
false
Compiler error
Runtime error
true
false
Compiler error
Runtime error
true
false
Compiler error
Runtime error
0
10
Compiler error
5
0
10
Compiler error
5
true
false
Compiler error
No output025
true
false
Compiler error
10
false
11
true
12
false
12
Compiler error
20
25
Compiler error
Runtime error
12
11
Compiler error
Runtime error
-128
128
Compiler error
Runtime error
-128
128
Compiler error
Runtime error
true
false
Compiler error
Runtime error
true
false
Compiler error
Runtime error
6
10
5
10
6
11
No output
6
10
5
10
6
11
No output
6
10
5
10
6
11
No output
6
10
5
10
6
11
No output
6
10
12
5
10
11
6
11
12
No output
6
10
11
5
10
11
6
11
12
No output
6
11
11
5
10
11
6
10
12
No output
6
11
11
5
10
11
6
10
12
No output
6
11
12
5
10
11
6
10
12
No output
6
11
12
5
10
11
6
10
11
No output
6
11
11
5
10
11
6
10
11
No output
6
11
11
5
10
11
6
10
11
No output
6
11
11
12
5
10
11
12
6
10
11
12
No output
6
11
12
13
5
10
11
12
6
11
12
12
No output
6
11
12
13
5
10
11
12
6
11
12
12
No output
6
11
12
13
5
10
11
12
6
11
11
12
No output
6
11
12
13
5
10
11
12
6
11
11
12
No output
6
11
12
13
5
10
11
12
6
11
11
12
No output
