Class 12

Information Technology (802)

351 questions available

Refine

All questions

351 results
201

Which prebuilt class, from the java.util package, is commonly used to take user input from the console?

MCQ Easy
a. Scanner
b. Reader
c. Input
d. Console
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
Scanner
Explanation: The Scanner class (from java.util) is used to take input from the console via System.in.
202

Which Scanner method reads the next token from the input stream and returns it as a String?

MCQ Easy
a. next()
b. read()
c. getInput()
d. scan()
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
next()
Explanation: The next() method of the Scanner class reads a token from input and returns it as a String.
203

Which static method of the Integer class converts a String to its integer equivalent?

MCQ Easy
a. toString()
b. parseInt()
c. valueOf()
d. intValue()
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
parseInt()
Explanation: Integer.parseInt(String) is a static method that converts a String into its equivalent int value.
204

Which class (from java.util) provides prebuilt methods like sort() and binarySearch() for manipulating arrays?

MCQ Easy
a. Scanner
b. Arrays
c. Collections
d. String
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
Arrays
Explanation: The Arrays class (java.util package) provides methods such as sort() and binarySearch() for array manipulation.
205

What must be true about an array BEFORE using Arrays.binarySearch() on it?

MCQ Medium
a. It must contain only Strings
b. It must be sorted
c. It must have exactly 5 elements
d. It must be empty
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
It must be sorted
Explanation: The array must be sorted before invoking binarySearch(); otherwise, the results are undefined.
206

What does Arrays.binarySearch() return if the key element is NOT found in the array?

MCQ Medium
a. 0
b. -1
c. null
d. The array length
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
-1
Explanation: If the key is not found, the binarySearch() method returns -1.
207

Which String class method converts all characters of a string to uppercase?

MCQ Easy
a. toUpperCase()
b. toLowerCase()
c. capitalize()
d. upper()
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
toUpperCase()
Explanation: The toUpperCase() method converts a String to all uppercase letters.
208

For myString = "Hello World", what does myString.charAt(6) return?

MCQ Medium
a. H
b. W
c. o
d. d
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
W
Explanation: Index 6 in 'Hello World' (0-indexed: H-0,e-1,l-2,l-3,o-4, -5,W-6) corresponds to the character 'W'.
209

For myString = "Hello World", what does myString.length() return?

MCQ Medium
a. 10
b. 11
c. 12
d. 5
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
11
Explanation: 'Hello World' has 11 characters including the space, so length() returns 11.
210

Which String method checks if a string contains a given substring, returning true/false?

MCQ Easy
a. indexOf()
b. contains()
c. concat()
d. replace()
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
contains()
Explanation: The contains(String s) method returns true if the string contains the specified substring.
211

Which String method compares two strings for equality WITHOUT considering case sensitivity?

MCQ Medium
a. equals()
b. equalsIgnoreCase()
c. compareTo()
d. matches()
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
equalsIgnoreCase()
Explanation: equalsIgnoreCase(String another) compares two strings for equality while ignoring case differences.
212

For myString = "Hello World", what does myString.replace('l','*') return?

MCQ Medium
a. He**o Wor*d
b. Hello World
c. HE**O WOR*D
d. He*lo Wor*d
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
He**o Wor*d
Explanation: The replace() method replaces ALL occurrences of the character 'l' with '*', giving 'He**o Wor*d'.
213

Once the Arrays class has sorted an array, the sort is applied in ascending order by default using Arrays.sort().

TRUE FALSE Easy
a. TRUE
b. FALSE
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
TRUE
Explanation: Arrays.sort() sorts an array (of numbers or Strings) in ascending order by default.
214

The Integer class and its parseInt() method must be manually imported using the import statement, similar to the Scanner class.

TRUE FALSE Hard
a. TRUE
b. FALSE
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
FALSE
Explanation: The Integer class is part of the java.lang package, which is automatically imported into all Java programs by default, so no explicit import statement is needed.
215

Write the two lines of code needed to create a Scanner object that reads from the console and stores a name entered by the user.

SHORT Easy
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
Explanation: Scanner user_input = new Scanner(System.in); String name = user_input.next();
216

Data that has not been processed to reveal useful meaning is called:

MCQ Easy
a. Information
b. Data
c. Metadata
d. A Query
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
Data
Explanation: Data is a collection of raw facts which have not been processed to reveal useful information.
217

Write Java code to declare an array of 5 doubles with values {103, 144, 256.5, 346, 387.5}, sort it using the Arrays class, and then print the lowest and highest marks.

LONG Medium
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
Explanation: import java.util.Arrays; double[] marks = {103, 144, 256.5, 346, 387.5}; Arrays.sort(marks); System.out.println(marks[0]); // lowest System.out.println(marks[marks.length-1]); // highest
218

Which of the following best describes 'Information'?

MCQ Easy
a. Raw unprocessed facts
b. Data produced by processing raw facts to reveal meaning
c. A collection of tables
d. A database query
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
Data produced by processing raw facts to reveal meaning
Explanation: Information is produced by processing data, revealing something meaningful (e.g. average marks computed from individual student marks).
219

An unexpected error situation during program execution that causes it to terminate abnormally is called:

MCQ Easy
a. A syntax error
b. An exception
c. A comment
d. A constructor
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
An exception
Explanation: An exception is an error situation, unexpected during program execution, that causes abnormal termination if not handled.
220

Which of the following is NOT a property of a database?

MCQ Medium
a. It represents some aspect of the real world (mini-world)
b. It is designed and built for a specific purpose
c. It must always be very small in size
d. It can be maintained manually or be computerized
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
It must always be very small in size
Explanation: A database can be of any size and complexity; there is no requirement that it must be small.