A question bank for every class and subject

Practice questions, with answers and explanations included

794 questions available

Refine

All questions

794 results
541

Write an SQL query to display PrName and UnitPrice of products whose name contains the word 'Exerciser' from table GYM.

SHORT Medium
Information Technology (802) · Class 11 · Sep 26, 2026
Show answer
Explanation: SELECT PrName, UnitPrice FROM GYM WHERE PrName LIKE '%Exerciser%';
542

Design a Java class 'Book' with private data members Title, Author, Publisher, Genre (all String) and Price (double). Include a parameterized constructor, a getter and setter for Price (the setter should not allow price below 100), and a display() method.

LONG Hard
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
Explanation: class Book { private String Title, Author, Publisher, Genre; private double Price; Book(String t, String a, String p, String g, double pr) { Title=t; Author=a; Publisher=p; Genre=g; Price=pr; } double getPrice() { return Price; } void setPrice(double newprice) { if (newprice < 100) System.out.println("Price cannot be set lower than 100!"); else Price = newprice; } void display() { System.out.println(Title+" "+Author+" "+Publisher+" "+Genre+" "+Price); } }
543

Which method converts a String value to an int in Java?

MCQ Medium
a. String.parseInt()
b. Integer.parseInt()
c. Integer.toString()
d. Double.parseDouble()
Information Technology (802) · Class 11 · Sep 26, 2026
Show answer
Integer.parseInt()
Explanation: Integer.parseInt() is used to convert a String value (e.g., from a text field) to an int value.
544

Write an SQL query to display Name and cost of shoes with size greater than 8 from table Shoes.

SHORT Medium
Information Technology (802) · Class 11 · Sep 26, 2026
Show answer
Explanation: SELECT Name, cost FROM Shoes WHERE size > 8;
545

Which keyword is used to bring a prebuilt Java class into a program for use?

MCQ Easy
a. include
b. import
c. using
d. require
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
import
Explanation: The keyword 'import' is used to bring a prebuilt class from a package into scope for use in a program.
546

Which method converts an integer value to a String in Java?

MCQ Medium
a. Integer.parseInt()
b. String.valueOf()
c. Integer.toString()
d. Both Integer.toString() and String.valueOf()
Information Technology (802) · Class 11 · Sep 26, 2026
Show answer
Both Integer.toString() and String.valueOf()
Explanation: Both Integer.toString() and String.valueOf() convert an int value into its String representation.
547

Write an SQL query to display Name and cost of shoes with cost less than 2000 from table Shoes.

SHORT Medium
Information Technology (802) · Class 11 · Sep 26, 2026
Show answer
Explanation: SELECT Name, cost FROM Shoes WHERE cost < 2000;
548

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.
549

In the code: if(condition) { statementBlock1; } else { statementBlock2; } — what happens if the condition evaluates to false?

MCQ Easy
a. statementBlock1 executes
b. statementBlock2 executes
c. Both execute
d. Neither executes
Information Technology (802) · Class 11 · Sep 26, 2026
Show answer
statementBlock2 executes
Explanation: If the condition is false, control passes to the else clause and statementBlock2 is executed.
550

Write an SQL query to display Name and cost of shoes of type 'Sports' from table Shoes.

SHORT Medium
Information Technology (802) · Class 11 · Sep 26, 2026
Show answer
Explanation: SELECT Name, cost FROM Shoes WHERE type = 'Sports';
551

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.
552

Curly braces {} are mandatory around a statement block in an if statement when:

MCQ Medium
a. There is exactly one statement
b. There are multiple statements
c. The condition is always true
d. Never required
Information Technology (802) · Class 11 · Sep 26, 2026
Show answer
There are multiple statements
Explanation: Curly braces are optional for a single statement but mandatory when a block contains multiple statements.
553

Write an SQL query to display Name and cost of shoes with quantity in stock less than 10 from table Shoes.

SHORT Medium
Information Technology (802) · Class 11 · Sep 26, 2026
Show answer
Explanation: SELECT Name, cost FROM Shoes WHERE Qty < 10;
554

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.
555

A switch statement is generally preferred over multiple if/else-if statements when:

MCQ Medium
a. Testing a range of values
b. Selection is based on a single value compared against multiple constants
c. Testing boolean conditions only
d. There is only one condition to check
Information Technology (802) · Class 11 · Sep 26, 2026
Show answer
Selection is based on a single value compared against multiple constants
Explanation: A switch statement is easier to read and more appropriate than long if/else-if chains when selection is based on a single value.
556

Write the SQL statement to display the structure of the table 'Shoes'.

SHORT Easy
Information Technology (802) · Class 11 · Sep 26, 2026
Show answer
Explanation: DESCRIBE Shoes; (or DESC Shoes;)
557

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.
558

In Java, a variable must be declared before it can be used.

TRUE FALSE Easy
a. TRUE
b. FALSE
Information Technology (802) · Class 11 · Sep 26, 2026
Show answer
TRUE
Explanation: Java requires all variables to be declared (with a data type) before use.
559

Write the SQL statement to view the names of all tables in the currently selected database.

SHORT Easy
Information Technology (802) · Class 11 · Sep 26, 2026
Show answer
Explanation: SHOW TABLES;
560

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.