Question bank

Class 12

1 subject · 351 questions

Refine

All questions

351 results
41

An attribute used in the GROUP BY clause must also appear:

MCQ Medium
a. In the WHERE clause
b. In the SELECT clause
c. In the HAVING clause only
d. It need not appear anywhere else
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
In the SELECT clause
Explanation: The attribute(s) used for grouping (e.g., Dept_No) must also be present in the SELECT clause.
42

How many times does the loop body execute? for(int count=3; count<=15; count = count + 3)

MCQ Medium
a. 5
b. 6
c. 4
d. 7
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
5
Explanation: The loop runs from count=3 while count<=15, stepping by 3 each time, giving 5 iterations.
43

A SELECT query that finds no matching rows results in:

MCQ Easy
a. A syntax error
b. An empty set
c. NULL being returned
d. The query automatically retries
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
An empty set
Explanation: If no rows match the query's condition, the result is simply an empty set — this is not an error.
44

For String myString = "Computer Science"; what does myString.length() return?

MCQ Easy
a. 16
b. 15
c. 17
d. 0
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
16
Explanation: 'Computer Science' contains 16 characters including spaces, so length() returns 16.
45

Using arithmetic operators (like *, +, -) is allowed directly within a SELECT clause, e.g., Salary*1.1 AS New_Salary.

TRUE FALSE Medium
a. TRUE
b. FALSE
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
TRUE
Explanation: Arithmetic operators can be used in the SELECT clause to compute derived values, e.g., Salary*1.1 AS New_Salary to compute a 10% raise.
46

For String myString = "Computer Science"; what does myString.toUpperCase() return?

MCQ Easy
a. COMPUTER SCIENCE
b. computer science
c. Computer Science
d. ecneicS retupmoC
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
COMPUTER SCIENCE
Explanation: toUpperCase() converts every character in 'Computer Science' to uppercase: 'COMPUTER SCIENCE'.
47

Boolean operators AND and OR can be used within a WHERE clause to combine multiple conditions.

TRUE FALSE Easy
a. TRUE
b. FALSE
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
TRUE
Explanation: AND and OR can combine multiple conditions in a WHERE clause, e.g., WHERE Dept_No = 4 OR Dept_No = 7.
48

For String myString = "Database System"; what does myString.length() return?

MCQ Easy
a. 15
b. 14
c. 16
d. 0
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
15
Explanation: 'Database System' contains 15 characters including spaces, so length() returns 15.
49

A nested (subquery) approach can always be rewritten using an equivalent JOIN-based query for these kinds of examples.

TRUE FALSE Hard
a. TRUE
b. FALSE
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
TRUE
Explanation: As shown in the textbook, a query using a subquery with IN can be rewritten as an equivalent JOIN query with WHERE Dept_ID = Dept_No AND condition.
50

For String myString = "Database System"; what does myString.toUpperCase() return?

MCQ Easy
a. DATABASE SYSTEM
b. database system
c. Database System
d. metsyS esabataD
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
DATABASE SYSTEM
Explanation: toUpperCase() converts every character in 'Database System' to uppercase: 'DATABASE SYSTEM'.
51

Write an SQL query to retrieve all information about the Teacher with Teacher_ID = 101.

SHORT Easy
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
Explanation: SELECT * FROM Teacher WHERE Teacher_ID = 101;
52

For String myString = "Java Programming"; what does myString.length() return?

MCQ Easy
a. 16
b. 15
c. 17
d. 0
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
16
Explanation: 'Java Programming' contains 16 characters including spaces, so length() returns 16.
53

Write an SQL query to find the first and last names of all teachers earning more than 50000.

SHORT Easy
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
Explanation: SELECT First_Name, Last_Name FROM Teacher WHERE Salary > 50000;
54

For String myString = "Java Programming"; what does myString.toUpperCase() return?

MCQ Easy
a. JAVA PROGRAMMING
b. java programming
c. Java Programming
d. gnimmargorP avaJ
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
JAVA PROGRAMMING
Explanation: toUpperCase() converts every character in 'Java Programming' to uppercase: 'JAVA PROGRAMMING'.
55

Write an SQL query to display Teacher_ID, First_Name, Last_Name and Dept_No of teachers who belong to department number 4 or 7.

SHORT Medium
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
Explanation: SELECT Teacher_ID, First_Name, Last_Name, Dept_No FROM Teacher WHERE Dept_No = 4 OR Dept_No = 7;
56

Write an SQL query using a join to retrieve names of all teachers and the names/numbers of their respective departments.

SHORT Medium
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
Explanation: SELECT First_Name, Last_Name, Dept_ID, Dept_Name FROM Teacher, Department WHERE Dept_ID = Dept_No;
57

Write an SQL query to retrieve the names of teachers working in the Chemistry department (using a join).

SHORT Medium
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
Explanation: SELECT First_Name, Last_Name FROM Teacher, Department WHERE Dept_ID = Dept_No AND Dept_Name = 'Chemistry';
58

Write an SQL query using table aliases T (Teacher) and D (Department) to retrieve names of teachers in the Hindi department.

SHORT Medium
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
Explanation: SELECT First_Name, Last_Name FROM Teacher AS T, Department AS D WHERE D.Dept_ID = T.Dept_ID AND Dept_Name = 'Hindi';
59

Write an SQL query to list distinct department numbers having male teachers.

SHORT Medium
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
Explanation: SELECT DISTINCT Dept_No FROM Teacher WHERE Gender = 'M';
60

Write an SQL query to retrieve names of teachers whose first name starts with the letter 'S'.

SHORT Easy
Information Technology (802) · Class 12 · Sep 26, 2026
Show answer
Explanation: SELECT First_Name FROM Teacher WHERE First_Name LIKE 'S%';