1. Q1: What is MySQL, and how does it differ from other database management systems?
- A1: MySQL is an open-source relational database management system (RDBMS). It differs in terms of
its open-source nature and widespread use.
2. Q2: Write an SQL command to create a new database in MySQL.
- A2: CREATE DATABASE database_name;
Example: CREATE DATABASE Student;
3. Q3: How do you select a database for use in MySQL?
- A3: USE database_name;
Example: USE Student;
4. Q4: Write an SQL command to create a table named 'Students' with columns for 'Name,' 'Roll
Number,' and 'Marks.'
- A4: CREATE TABLE Students (Name VARCHAR(50), RollNumber INT, Marks INT);
5. Q5: How can you insert data into the 'Students' table?
- A5: INSERT INTO Students (Name, RollNumber, Marks) VALUES ('John Doe', 101, 85);
OR
INSERT INTO Students VALUES(“John Doe”,101,85);
6. Q6: What is the purpose of the SELECT statement in MySQL?
- A6: It is used to retrieve data from one or more tables.
7. Q7: How can you display all columns from the 'Students' table?
- A7: SELECT * FROM Students;
8. Q8: Write an SQL query to display only the students with marks greater than 90.
- A8: SELECT * FROM Students WHERE Marks > 90;
9. Q9: How do you sort the result of a query in descending order based on the 'Marks' column?
- A9: SELECT * FROM Students ORDER BY Marks DESC;
10. Q10: What is the purpose of the UPDATE statement in MySQL?
- A10: It is used to modify existing records in a table.
11. Q11: Write an SQL command to delete a record with RollNumber 102 from the 'Students' table.
- A11: DELETE FROM Students WHERE RollNumber = 102;
12. Q12: Explain the concept of a JOIN operation in MySQL.
- A12: JOIN combines rows from two or more tables based on a related column between them.
13. Q13: Write an SQL query to retrieve data from two tables, 'Students' and 'Courses,' based on a
common 'StudentID' column.
- A13: SELECT * FROM Students INNER JOIN Courses ON Students.StudentID = Courses.StudentID;
14. Q14: What is the purpose of aggregate functions in MySQL?
- A14: Aggregate functions perform calculations on a set of values and return a single result.
15. Q15: Write an SQL query to find the average marks of all students.
- A15: SELECT AVG(Marks) FROM Students;
16. Q16: Explain the concept of a subquery in MySQL.
- A16: A subquery is a query nested within another query, providing a way to retrieve data needed for
the main query.
17. Q17: Write an SQL query using a subquery to find students with marks greater than the average
marks.
- A17: SELECT * FROM Students WHERE Marks > (SELECT AVG(Marks) FROM Students);
18. Q18: What are the ACID properties in the context of database transactions?
- A18: ACID stands for Atomicity, Consistency, Isolation, and Durability, ensuring reliable and secure
transactions.
19. Q19: How does MySQL ensure data durability in a transaction?
- A19: MySQL ensures durability by persistently storing committed changes even in the event of a
system failure.
20. Q20: Why are indexes important in MySQL databases?
- A20: Indexes improve the speed of data retrieval operations by providing a quick reference to the
location of data.
Basic JAVA questions for VIVA
Q1: What is the purpose of the "public" keyword in Java?
A1: The "public" keyword is an access modifier used to declare a member (method, variable,
class) as accessible from any other class.
Q2: Explain the role of the "static" keyword in a Java method.
A2: The "static" keyword in a method declaration indicates that the method belongs to the class
rather than an instance of the class. It can be called without creating an object.
Q3: How is an object created in Java?
A3: An object is created using the "new" keyword followed by the class constructor. For
example: ClassName objectName = new ClassName();
Q4: What is the significance of the "void" keyword in a Java method signature?
A4: The "void" keyword indicates that the method does not return any value.
Q5: Define the term "inheritance" in Java.
A5: Inheritance is a mechanism in Java that allows a class to inherit properties and behaviors
from another class. It promotes code reuse.
Q6: What is the purpose of the "this" keyword in Java?
A6: The "this" keyword refers to the current object instance. It is used to distinguish instance
variables from local variables and to invoke methods.
Q7: Differentiate between "compile-time error" and "runtime error" in Java.
A7: Compile-time errors are detected by the compiler during code compilation, while runtime
errors occur during program execution.
Q8: Explain the role of the "super" keyword in Java.
A8: The "super" keyword is used to refer to the superclass or parent class. It is often used to call
methods or access members of the superclass.
Q9: What is the purpose of the "break" statement in Java?
A9: The "break" statement is used to terminate the loop or switch statement it is in,
transferring control to the statement following the loop or switch.