Class 12

Information Technology (802)

351 questions available

Refine

All questions

351 results
121

Which primitive data type stores a single character and occupies 16 bits?

MCQ Easy
a. byte
b. short
c. char
d. boolean
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
char
Explanation: The char data type stores character values and occupies 16 bits in Java.
122

Which of the following is NOT a valid Java variable name?

MCQ Medium
a. total_marks
b. _score
c. $value
d. total marks
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
total marks
Explanation: Variable names must be a single word without spaces; 'total marks' contains a space and is invalid, while underscores and dollar signs are permitted characters.
123

Which statement about Java variable names is TRUE?

MCQ Medium
a. Java is not case-sensitive for variable names
b. 'percentage' and 'Percentage' refer to the same variable
c. Java is case-sensitive; 'percentage' and 'PERCENTAGE' are different variables
d. Variable names cannot contain digits
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
Java is case-sensitive; 'percentage' and 'PERCENTAGE' are different variables
Explanation: Java is a case-sensitive language, so 'percentage', 'Percentage', and 'PERCENTAGE' are all considered different variable names.
124

To store textual data of more than one character in Java, which class/type is used?

MCQ Easy
a. char
b. String
c. int
d. boolean
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
String
Explanation: The String class is used to store text values of more than one character; text is enclosed in double quotes.
125

When the + operator is used with two String operands in Java, what does it do?

MCQ Easy
a. Adds their ASCII values
b. Concatenates (joins) the strings
c. Causes a compile error
d. Compares the strings
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
Concatenates (joins) the strings
Explanation: When used with String operands, the + operator concatenates (joins) the strings together.
126

Which arithmetic operator returns the remainder of division of two operands?

MCQ Easy
a. /
b. %
c. //
d. \
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
%
Explanation: The modulus operator (%) returns the remainder of the division of its operands.
127

Given int a=20, b=30; what is the value of a/b in Java (integer division)?

MCQ Medium
a. 0
b. 1
c. 0.67
d. 50
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
0
Explanation: In integer division, 20/30 evaluates to 0 since the quotient is truncated (fraction discarded).
128

Given int a=20, b=30; what is the result of the expression a%b?

MCQ Medium
a. 0
b. 10
c. 20
d. 1.5
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
20
Explanation: a % b returns the remainder of a divided by b: 20 % 30 = 20 (since 20 is less than 30, the whole of a is the remainder).
129

Which operator returns true if the values of both operands are equal, and is NOT to be confused with the assignment operator?

MCQ Easy
a. =
b. ==
c. :=
d. ===
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
==
Explanation: The == operator is the relational 'equal to' operator; = is the assignment operator, a common source of confusion for beginners.
130

Given int a=20, b=30; which relational expression evaluates to TRUE?

MCQ Easy
a. a==b
b. a>b
c. a<b
d. a>=b
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
a<b
Explanation: a<b (20<30) evaluates to true; a==b, a>b, and a>=b are all false.
131

Which assignment operator is shorthand for 'a = a + b'?

MCQ Easy
a. a =+ b
b. a += b
c. a -= b
d. a *= b
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
a += b
Explanation: The += operator adds the right operand's value to the left operand and assigns the result, equivalent to a = a + b.
132

Which logical operator returns true if the values of EITHER operand a or b are true?

MCQ Easy
a. &&
b. ||
c. !
d. ==
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
||
Explanation: The logical OR (||) operator returns true if either (or both) of the operands are true.
133

Which logical operator negates the value of its single operand (true becomes false, and vice versa)?

MCQ Easy
a. &&
b. ||
c. !
d. ^
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
!
Explanation: The logical NOT (!) operator returns true if the operand is false, and false if the operand is true.
134

A compiler is needed to translate a high level programming language like Java into machine language understood by the computer.

TRUE FALSE Easy
a. TRUE
b. FALSE
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
TRUE
Explanation: Since a computer only understands machine language, a compiler is needed to translate high-level code (like Java) into a form the computer/JVM can execute.
135

All Java statements must end with a semicolon.

TRUE FALSE Easy
a. TRUE
b. FALSE
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
TRUE
Explanation: In Java, every statement must be terminated with a semicolon (;).
136

A local variable in Java is available throughout the entire program, regardless of which method it was declared in.

TRUE FALSE Medium
a. TRUE
b. FALSE
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
FALSE
Explanation: A local variable is available only inside the method where it was declared, not throughout the whole program.
137

You can declare multiple variables of the same type in a single statement using commas, e.g., int num1, num2, num3;

TRUE FALSE Easy
a. TRUE
b. FALSE
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
TRUE
Explanation: Java allows declaring multiple variables of the same type in one statement, separated by commas.
138

What is Java Bytecode?

SHORT Medium
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
Explanation: Java Bytecode is a highly optimized set of instructions produced when a Java compiler compiles Java source code. It is platform-independent and is executed by the Java Virtual Machine (JVM) on any platform.
139

Name the eight primitive data types available in Java.

SHORT Easy
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
Explanation: byte, short, int, long, float, double, char, and boolean.
140

Given int a = 20, b = 30, evaluate the following Java expressions: (i) a%b (ii) a/=b (iii) (a+b*100)/10 (iv) a&&b (v) a++

LONG Hard
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
Explanation: (i) a%b = 20 (since 20 < 30, the remainder is 20 itself). (ii) a/=b means a = a/b = 20/30 = 0 (integer division), so a becomes 0. (iii) (a+b*100)/10: multiplication first (b*100=3000), then addition (20+3000=3020), then division (3020/10=302). (iv) a&&b is invalid in Java as && requires boolean operands, not integers — this would cause a compile-time error. (v) a++ (post-increment) returns 20 (the value before incrementing), after which a becomes 21.