0% found this document useful (0 votes)
4 views

Second Performance Test

The document outlines tasks related to programming and database management, including defining classes for books and voters, explaining inheritance in OOP, and creating a Library Management System. It also includes SQL tasks such as creating an Employee table, inserting records, and querying employee details based on various conditions. The document emphasizes code reusability, maintainability, and provides specific examples and queries to manipulate and retrieve data.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Second Performance Test

The document outlines tasks related to programming and database management, including defining classes for books and voters, explaining inheritance in OOP, and creating a Library Management System. It also includes SQL tasks such as creating an Employee table, inserting records, and querying employee details based on various conditions. The document emphasizes code reusability, maintainability, and provides specific examples and queries to manipulate and retrieve data.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1. Define a class Book with attributes: title, author, and price.

Write a method to display book


details.

2. Create a class Voter with an age field and a method CanVote() that returns a boolean indicating
if the person is eligible to vote (age >= 18).

3. Explain the concept of inheritance in Object-Oriented Programming (OOP). How does it help
with code reusability and maintainability? Provide 5 examples.

4. Create a Library Management System that will store the following information for each book:
Title (string), Author (string), ISBN (string), Year Published (integer). Store data for at least 5
books and print the information.

5. Create a table named Employee with the following columns and constraints:

- EmpID: An INT column that should be the Primary Key.


- EmpName: A VARCHAR column that must NOT be NULL.
- EmpJob: A VARCHAR column that must have a UNIQUE constraint.
- EmpSalary: An INT column that should explicitly allow NULL values.

6. Write the SQL INSERT INTO statements for inserting these 10 records.

EmpID EmpName EmpJob EmpSalary


1 Ali Khan Manager 80000
2 Sara Ahmed Analyst 65000
3 Usman Rafiq Developer 70000
4 Ayesha Noor Tester 60000
5 Bilal Saeed Designer 55000
6 Nida Qureshi Support NULL
7 Fahad Iqbal Trainer 58000
8 Mariam Khan HR 62000
9 Zain Ali Consultant NULL
10 Hira Shah Coordinator 61000

7. Write a query to display all employee details whose EmpJob is either 'Manager', 'HR', or
'Trainer'.

8. Write a query to display the employees whose EmpSalary is between 60,000 and 70,000.

9. Write a query to display all employees whose salary is less than 60000.
10. Write a query Display all employees whose salary is greater than 65000.

11. Write a query to display all employees who are not Analysts.
12. Write a query to find employees whose salary is not entered yet (NULL)
13. Write a query to find employees whose names start with 'A'.
14. Write a query to Display all employees whose job title contains the word 'er' (e.g., 'Manager',
'Designer').
15. Write a query to Display employees whose job is not 'Developer', 'Tester', or 'Support'.
16. Write a query to List all employees who have a salary value entered (i.e., salary is not NULL).
17. Write a query to Display employees whose job is 'Trainer' and salary is greater than 50000.
18. Write a query to Find employees whose second letter in the name is 'a' (e.g., 'Sara', 'Mariam').
19. Write a query to display employees whose job is not one of the following: 'Coordinator',
'Consultant', 'Support'.
20. Write a query to Display all employees whose name has exactly 5 characters.
21. Write a Query Find employees whose job title starts with 'De' (e.g., 'Developer', 'Designer').
22. Write a query to display all employees sorted by EmpSalary in descending order.
23. Display employees sorted first by highest EmpSalary, and if salaries are equal, then sort by
EmpName.
24. Write a query to get the top 3 highest-paid employees.
25. Make the following changes in the Employee table
- Add a Primary Key constraint to the EmpID column (assuming EmpID is currently not a
primary key).
- Remove the Primary Key constraint (if any) from the EmpID column and add it to the
EmpJob column instead.

You might also like