1) Write a program to cover all Java OOPS concepts.
Topics need to cover: a) Class and Object
b) Class constructor c) Method overloading d) Method overriding e) Inheritance f) Interface
g) Abstract class
Answer-
package com.question1.oops_concept;
// a) Class and Object
class Movie
String title;
String director;
int duration;
// b) Class constructor
public Movie(String t, String d, int dur)
title = t;
director = d;
duration = dur;
// c) Method overloading
void displayInfo()
System.out.println("Title: " + title);
System.out.println("Director: " + director);
System.out.println("Duration: " + duration + " minutes");
void displayInfo(boolean showDuration)
System.out.println("Title: " + title);
System.out.println("Director: " + director);
if (showDuration)
System.out.println("Duration: " + duration + " minutes"); } }
// e) Inheritance and d) Method overriding
class AnimatedMovie extends Movie
String animationStudio;
AnimatedMovie(String t, String d, int dur, String studio)
super(t, d, dur);
animationStudio = studio;
// Method overriding
void displayInfo()
super.displayInfo();
System.out.println("Animation Studio: " + animationStudio);
// f) Interface
interface MovieOperations
void watchMovie();
void rateMovie(int rating);
// g) Abstract class
abstract class Viewer
String name;
Viewer(String n)
name = n;
abstract void displayViewerInfo(); }
class MovieFan extends Viewer implements MovieOperations
int favoriteMovieId;
MovieFan(String n, int favId)
super(n);
favoriteMovieId = favId;
void displayViewerInfo()
System.out.println("Viewer Name: " + name);
System.out.println("Favorite Movie ID: " + favoriteMovieId);
public void watchMovie()
System.out.println(name + " is watching a movie.");
public void rateMovie(int rating)
System.out.println(name + " rated the movie " + rating + " out of 5.");
public class MovieSystem {
public static void main(String[] args)
// Creating objects
Movie movie1 = new Movie("Inception", "Christopher Nolan", 148);
AnimatedMovie animatedMovie1 = new AnimatedMovie("Toy Story", "John Lasseter", 81,
"Pixar");
// Method overloading
movie1.displayInfo();
movie1.displayInfo(false);
// Method overriding
animatedMovie1.displayInfo();
// Abstract class and interface demonstration
MovieFan fan = new MovieFan("Srushti", 101);
fan.displayViewerInfo();
fan.watchMovie();
fan.rateMovie(5);
Output 1-
2. Design a Java program that performs various string operations and uses control
statements for user input validation. The program should allow the user to perform the
following operations:
a) Extract Substring: The user can enter a string and specify the starting and ending
index, and the program should extract and display the substring.
b) Split a Sentence: The user can enter a sentence, and the program should split it
into words and display them.
Answer-
package com.question2.string_Concept;
import java.util.Scanner;
public class StringOperations {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (true) {
// Display menu
System.out.println("Choose an operation:");
System.out.println("1. Extract Substring");
System.out.println("2. Split a Sentence");
System.out.println("3. Exit");
// Get user choice
int choice = scanner.nextInt();
scanner.nextLine(); // consume the newline
switch (choice) {
case 1:
// Extract Substring
System.out.print("Enter a string: ");
String inputString = scanner.nextLine();
System.out.print("Enter the starting index: ");
int startIndex = scanner.nextInt();
System.out.print("Enter the ending index: ");
int endIndex = scanner.nextInt();
scanner.nextLine(); // consume the newline
if (startIndex >= 0 && endIndex <= inputString.length() && startIndex < endIndex) {
String substring = inputString.substring(startIndex, endIndex);
System.out.println("Extracted substring: " + substring);
} else {
System.out.println("Invalid indexes, please try again.");
break;
case 2:
// Split a Sentence
System.out.print("Enter a sentence: ");
String sentence = scanner.nextLine();
String[] words = sentence.split(" ");
System.out.println("Words in the sentence:");
for (String word : words) {
System.out.println(word);
break;
case 3:
// Exit
System.out.println("Exiting the program.");
System.exit(0);
default:
// Handle invalid choice
System.out.println("Invalid choice, please try again.");
} } } }
OUTPUT 2 –
1) 3. Design a Java program to implement a Collection Management System that manages
different types of collections such as lists, sets, and maps. The program should allow users
to perform the following operations for each type of collection:
a) Lists:
i) Add an element: The user can add an element to the list.
ii) Remove an element: The user can remove an element from the list.
iii) Display all elements: The user can view all elements in the list.
b) Sets:
i) Add an element: The user can add an element to the set.
ii) Remove an element: The user can remove an element from the set.
iii) Display all elements: The user can view all elements in the set.
iv) Implement exception handling to handle possible errors (e.g., element not
found in the list/set, duplicate keys in the map).
v) Provide a user-friendly console interface for the user to interact with the
Collection Management System.
Answer –
package com.question3.collectionmanagementsystem;
import java.util.*;
public class CollectionManagementSystem {
// Creating a list, set, and map to store elements
private static List<Object> list = new ArrayList<>();
private static Set<Object> set = new HashSet<>();
private static Map<Object, Object> map = new HashMap<>();
public static void main(String[] args)
Scanner scanner = new Scanner(System.in);
while (true)
// Displaying the main menu
System.out.println("Choose a collection type:");
System.out.println("1. List");
System.out.println("2. Set");
System.out.println("3. Map");
System.out.println("4. Exit");
int choice = scanner.nextInt();
scanner.nextLine();
switch (choice)
case 1:
performListOperations(scanner);
break;
case 2:
performSetOperations(scanner);
break;
case 3:
performMapOperations(scanner);
break;
case 4:
System.out.println("Exiting...");
System.exit(0);
default:
System.out.println("Invalid choice. Please enter a valid option.");
// Function to perform operations on a List
private static void performListOperations(Scanner scanner)
{
System.out.println("List Operations:");
System.out.println("1. Add an element");
System.out.println("2. Remove an element");
System.out.println("3. Display all elements");
int listChoice = scanner.nextInt();
scanner.nextLine();
// Handling list operations based on user input
if (listChoice == 1)
System.out.print("Enter element to add: ");
Object listElementToAdd = scanner.nextLine();
list.add(listElementToAdd);
System.out.println("Element added to the list.");
else if (listChoice == 2)
System.out.print("Enter element to remove: ");
Object listElementToRemove = scanner.nextLine();
if (list.remove(listElementToRemove))
System.out.println("Element removed from the list.");
else
System.out.println("Element not found in the list.");
else if (listChoice == 3)
{
System.out.println("List Elements:");
for (Object item : list)
System.out.println(item);
else
System.out.println("Invalid choice for list operation.");
// Function to perform operations on a Set
private static void performSetOperations(Scanner scanner)
System.out.println("Set Operations:");
System.out.println("1. Add an element");
System.out.println("2. Remove an element");
System.out.println("3. Display all elements");
int setChoice = scanner.nextInt();
scanner.nextLine(); // Consume newline
// Handling set operations based on user input
if (setChoice == 1)
System.out.print("Enter element to add: ");
Object setElementToAdd = scanner.nextLine();
if (set.add(setElementToAdd))
{
System.out.println("Element added to the set.");
else
System.out.println("Element already exists in the set.");
else if (setChoice == 2)
System.out.print("Enter element to remove: ");
Object setElementToRemove = scanner.nextLine();
if (set.remove(setElementToRemove))
System.out.println("Element removed from the set.");
else
System.out.println("Element not found in the set.");
else if (setChoice == 3)
System.out.println("Set Elements:");
for (Object item : set)
System.out.println(item);
else
System.out.println("Invalid choice for set operation."); } }
// Function to perform operations on a Map
private static void performMapOperations(Scanner scanner)
System.out.println("Map Operations:");
System.out.println("1. Add key-value pair");
System.out.println("2. Remove key-value pair");
System.out.println("3. Display all key-value pairs");
System.out.println("4. Get value for a key");
System.out.println("5. Check if key exists");
System.out.println("6. Clear map");
System.out.println("7. Get map size");
int mapChoice = scanner.nextInt();
scanner.nextLine(); // Consume newline
// Handling map operations based on user input
if (mapChoice == 1)
System.out.print("Enter key: ");
Object mapKey = scanner.nextLine();
System.out.print("Enter value for key: ");
Object mapValue = scanner.nextLine();
map.put(mapKey, mapValue);
System.out.println("Key-value pair added.");
else if (mapChoice == 2)
System.out.print("Enter key to remove: ");
Object mapKey = scanner.nextLine();
if (map.remove(mapKey) != null)
{
System.out.println("Key-value pair removed.");
else
System.out.println("Key not found in the map.");
else if (mapChoice == 3)
System.out.println("Key-value pairs in the map:");
for (Map.Entry<Object, Object> entry : map.entrySet())
System.out.println(entry.getKey() + " - " + entry.getValue());
else if (mapChoice == 4)
System.out.print("Enter key to get value for: ");
Object mapKey = scanner.nextLine();
Object value = map.get(mapKey);
if (value != null)
System.out.println("Value for key " + mapKey + ": " + value);
else
System.out.println("Key not found in the map.");
else if (mapChoice == 5)
{
System.out.print("Enter key to check: ");
Object mapKey = scanner.nextLine();
if (map.containsKey(mapKey))
System.out.println("Key found in the map.");
else
System.out.println("Key not found in the map.");
else if (mapChoice == 6)
map.clear();
System.out.println("Map cleared.");
else if (mapChoice == 7)
System.out.println("Map size: " + map.size());
else
System.out.println("Invalid choice for map operation.");
} }}
OUTPUT 3 –
List Operation
SET Operations –
Map Operations
2) 4. Add new employees: The user can add details like employee ID, name, department, and
salary.
a) Update employee details: The user can update the name, department, or salary of
an existing employee based on their employee ID.
b) Delete an employee: The user can delete an employee from the system based on
their employee ID.
c) Display all employees: The user can view a list of all employees and their details.
d) Search for an employee: The user can search for an employee by their employee ID
and view their details.
e) Requirements:
i) Use Object-Oriented Programming (OOP) principles and create an Employee
class with appropriate attributes and methods.
ii) Use appropriate data structures (e.g., ArrayList, HashMap) to store the
employee data.
iii) Implement exception handling to handle possible errors (e.g., invalid
employee ID, input validation).
iv) Provide a user-friendly console interface for the user to interact with the
Employee Management System.
Answer –
1.Employee .java ---->>
package com.question4.employeemanagementsystem;
public class Employee {
private int id;
private String name;
private String department;
private double salary;
public Employee(int id, String name, String department, double salary) {
this.id = id;
this.name = name;
this.department = department;
this.salary = salary;
// Getters and setters for all attributes
public int getId() {
return id;
public void setId(int id) {
this.id = id;
public String getName() {
return name;
public void setName(String name) {
this.name = name;
public String getDepartment() {
return department;
public void setDepartment(String department) {
this.department = department;
public double getSalary() {
return salary;
public void setSalary(double salary) {
this.salary = salary;
@Override
public String toString() {
return "Employee ID: " + id + ", Name: " + name + ", Department: " + department + ", Salary: " +
salary;
}
EmployeeManagementSystem.java --
package com.question4.employeemanagementsystem;
import java.util.HashMap;
import java.util.Scanner;
public class EmployeeManagementSystem {
private HashMap<Integer, Employee> employeeMap; // To store employees
private Scanner scanner; // To read user input
public EmployeeManagementSystem() {
employeeMap = new HashMap<>();
scanner = new Scanner(System.in);
// Method to add a new employee
public void addEmployee() {
System.out.print("Enter Employee ID: ");
int id = scanner.nextInt();
scanner.nextLine(); // Consume newline
System.out.print("Enter Name: ");
String name = scanner.nextLine();
System.out.print("Enter Department: ");
String department = scanner.nextLine();
System.out.print("Enter Salary: ");
double salary = scanner.nextDouble();
Employee employee = new Employee(id, name, department, salary);
employeeMap.put(id, employee);
System.out.println("Employee added successfully.");
}
// Method to update an existing employee
public void updateEmployee() {
System.out.print("Enter Employee ID to update: ");
int id = scanner.nextInt();
scanner.nextLine(); // Consume newline
if (employeeMap.containsKey(id)) {
Employee employee = employeeMap.get(id);
System.out.print("Enter new Name (or leave blank to keep current): ");
String name = scanner.nextLine();
if (!name.isEmpty()) {
employee.setName(name);
System.out.print("Enter new Department (or leave blank to keep current): ");
String department = scanner.nextLine();
if (!department.isEmpty()) {
employee.setDepartment(department);
System.out.print("Enter new Salary (or -1 to keep current): ");
double salary = scanner.nextDouble();
if (salary != -1) {
employee.setSalary(salary);
employeeMap.put(id, employee);
System.out.println("Employee updated successfully.");
} else {
System.out.println("Employee ID not found.");
}
// Method to delete an employee
public void deleteEmployee() {
System.out.print("Enter Employee ID to delete: ");
int id = scanner.nextInt();
if (employeeMap.remove(id) != null) {
System.out.println("Employee deleted successfully.");
} else {
System.out.println("Employee ID not found.");
// Method to display all employees
public void displayAllEmployees() {
if (employeeMap.isEmpty()) {
System.out.println("No employees to display.");
} else {
for (Employee employee : employeeMap.values()) {
System.out.println(employee);
// Method to search for an employee by ID
public void searchEmployee() {
System.out.print("Enter Employee ID to search: ");
int id = scanner.nextInt();
Employee employee = employeeMap.get(id);
if (employee != null) {
System.out.println(employee);
} else {
System.out.println("Employee ID not found.");
// Method to run the menu-based system
public void run() {
while (true) {
System.out.println("\nEmployee Management System");
System.out.println("1. Add Employee");
System.out.println("2. Update Employee");
System.out.println("3. Delete Employee");
System.out.println("4. Display All Employees");
System.out.println("5. Search Employee");
System.out.println("6. Exit");
System.out.print("Choose an option: ");
int choice = scanner.nextInt();
switch (choice) {
case 1:
addEmployee();
break;
case 2:
updateEmployee();
break;
case 3:
deleteEmployee();
break;
case 4:
displayAllEmployees();
break;
case 5:
searchEmployee();
break;
case 6:
System.out.println("Exiting...");
scanner.close();
return;
default:
System.out.println("Invalid choice. Please try again.");
// Main method to start the application
public static void main(String[] args) {
EmployeeManagementSystem system = new EmployeeManagementSystem();
system.run();
OUTPUT –
5. Design a Java program to create a simple employee management system using JDBC and MySQL
Connector/J. The program should allow users to perform the following operations:
a) Add a new employee: The user can enter details like employee ID, name, department, and
salary, and the program should add the employee to the database.
b) Update employee details: The user can update the name, department, or salary of an existing
employee based on their employee ID.
c) Delete an employee: The user can delete an employee from the database based on their
employee ID.
d) Display all employees: The program should retrieve and display a list of all employees and their
details from the database.
e) Requirements:
i) Use JDBC and MySQL Connector/J to connect to the MySQL database and perform CRUD
(Create, Read, Update, Delete) operations.
ii) Implement exception handling to handle possible errors during database interactions.
iii) Provide a user-friendly console interface for the user to interact with the employee
management system.
iv) f) Cover Java topics such as classes, methods, user input and output (I/O), and exception
handling. Note: Before running the program, make sure you have MySQL installed, create a
database named "employee_management," and a table named "employees" with columns: "id"
(INT, PRIMARY KEY), "name" (VARCHAR), "department" (VARCHAR), and "salary" (DOUBLE)
Answer-
package com.question5.jdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;
public class Employee_Management_System {
static final String URL = "jdbc:mysql://localhost:3306/employee_management";
static final String USER = "root";
static final String PASSWORD = "rootroot";
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
try {
Connection connection = DriverManager.getConnection(URL, USER, PASSWORD);
System.out.println("Connected to the database.");
while (true) {
System.out.println("\nEmployee Management System");
System.out.println("1. Add Employee");
System.out.println("2. Update Employee");
System.out.println("3. Delete Employee");
System.out.println("4. Display All Employees");
System.out.println("5. Exit");
System.out.print("Enter your choice: ");
int choice = scanner.nextInt();
scanner.nextLine();
if (choice == 1) {
// Addtion of New Employee
System.out.print("Enter Employee ID: ");
int id = scanner.nextInt();
scanner.nextLine();
System.out.print("Enter Employee Name: ");
String name = scanner.nextLine();
System.out.print("Enter Department: ");
String department = scanner.nextLine();
System.out.print("Enter Salary: ");
double salary = scanner.nextDouble();
String query = "INSERT INTO employees (id, name, department, salary) VALUES
(?, ?, ?, ?)";
PreparedStatement preparedStatement = connection.prepareStatement(query);
preparedStatement.setInt(1, id);
preparedStatement.setString(2, name);
preparedStatement.setString(3, department);
preparedStatement.setDouble(4, salary);
preparedStatement.executeUpdate();
System.out.println("Employee added successfully!");
else if (choice == 2) {
// Update employee details
System.out.print("Enter Employee ID to update: ");
int id = scanner.nextInt();
scanner.nextLine(); // Consume newline
System.out.print("Enter new Name: ");
String name = scanner.nextLine();
System.out.print("Enter new Department: ");
String department = scanner.nextLine();
System.out.print("Enter new Salary: ");
double salary = scanner.nextDouble();
String query = "UPDATE employees SET name = ?, department = ?, salary = ? WHERE id
= ?";
PreparedStatement preparedStatement = connection.prepareStatement(query);
preparedStatement.setString(1, name);
preparedStatement.setString(2, department);
preparedStatement.setDouble(3, salary);
preparedStatement.setInt(4, id);
int rowsUpdated = preparedStatement.executeUpdate();
if (rowsUpdated > 0) {
System.out.println("Employee updated successfully!");
} else {
System.out.println("Employee not found with ID: " + id);
else if (choice == 3) {
// Delete an employee
System.out.print("Enter Employee ID to delete: ");
int id = scanner.nextInt();
String query = "DELETE FROM employees WHERE id = ?";
PreparedStatement preparedStatement = connection.prepareStatement(query);
preparedStatement.setInt(1, id);
int rowsDeleted = preparedStatement.executeUpdate();
if (rowsDeleted > 0) {
System.out.println("Employee deleted successfully!");
else {
System.out.println("Employee not found with ID: " + id);
} }
else if (choice == 4) {
// Display Records of all employees
String query = "SELECT * FROM employees";
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query);
System.out.println("\nEmployee Details:");
while (resultSet.next())
int id = resultSet.getInt("id");
String name = resultSet.getString("name");
String department = resultSet.getString("department");
double salary = resultSet.getDouble("salary");
System.out.printf("ID: %d, Name: %s, Department: %s, Salary: %.2f%n",
id, name, department, salary);
} }
else if (choice == 5) {
// Exit the program
System.out.println("Exiting the system. Goodbye!");
break;
else {
// Handle invalid choice
System.out.println("Invalid choice! Please try again.");
} }
// Closing the connection
connection.close();
} catch (SQLException e) {
System.out.println("Database connection error: " + e.getMessage());
OUTPUT –
7.Question
i. Write a query to display ename and job for all the employee with their half term salary
ii. Write a query to display all the details of the employees along with an annual bonus of 2000
iii.Write a query to display ename and salary with a hike of 10%.
iv. Write a query to display ename and salary with deduction of 25%."
8.Question
i. Write a query to display name and hire date of the employees if the employees were hired
during 1982 .
ii. Write a query to display name of the employee who gets salary as well as commission .
iii. Write a query to display name of the employee of employee has character 'A' as the second
character in the name.
9.Question
i. Write a query to display avg salary needed to pay all the employees in each department
excluding the employees of deptno 20.
ii. Write a query to display number of employees having character 'a' in their names in each job .
iii. Write a query to display maximum salaries given to an employee working in each dept
iv. Write a query to display ename and job of all the employees working in the same designation as
james.
v. Write a query to display ename and hiredate of the employees who's name end’s with 's' and
hired after james .
create table dept
(Deptno int(3) not null auto_increment,
Dname varchar(20) not null ,
Loc varchar(25) not null,
primary key(Deptno));
create table
Emp (
EMPNO INT(3) NOT NULL AUTO_INCREMENT,
ENAME VARCHAR(20) NOT NULL,
JOB VARCHAR(25) NOT NULL,
HIREDATE DATE ,
MGR INT(20),
SAL INT(10),
COMM INT(20),
DEPTNO INT(3),
PRIMARY KEY(EMPNO),
FOREIGN KEY(DEPTNO) REFERENCES DEPT(DEPTNO));
select*from dept;
INSERT INTO dept (Deptno, Dname, Loc)
VALUES
(10, 'Accounting', 'New York'),
(20, 'Research', 'Dallas'),
(30, 'Sales', 'Chicago'),
(40, 'Operations', 'Boston');
INSERT INTO emp (EMPNO, ENAME, JOB, HIREDATE, MGR, SAL, COMM, DEPTNO)
VALUES
(7369, 'SMITH', 'CLERK', '1980-12-17', 7902, 800, NULL, 20),
(7499, 'ALLEN', 'SALESMAN', '1981-02-20', 7698, 1600, 300, 30),
(7521, 'WARD', 'SALESMAN', '1981-02-22', 7698, 1250, 500, 30),
(7566, 'JONES', 'MANAGER', '1981-04-02', 7839, 2975, 1400, 20),
(7654, 'MARTIN', 'SALESMAN', '1981-09-28', 7698, 1250, NULL, 30),
(7698, 'BLAKE', 'MANAGER', '1981-05-01', 7839, 2850, NULL, 30),
(7782, 'CLARK', 'MANAGER', '1981-06-09', 7839, 2450, NULL, 10),
(7788, 'SCOTT', 'ANALYST', '1987-04-19', 7566, 3000, NULL, 20),
(7839, 'KING', 'PRESIDENT', '1981-11-17', NULL, 5000, NULL, 10),
(7844, 'TURNER', 'SALESMAN', '1981-09-08', 7698, 1500, 0, 30),
(7876, 'ADAMS', 'CLERK', '1987-05-23', 7788, 1100, NULL, 20),
(7900, 'JAMES', 'CLERK', '1981-12-03', 7698, 950, NULL, 30),
(7902, 'FORD', 'ANALYST', '1981-12-03', 7566, 3000, NULL, 20),
(7934, 'MILLER', 'CLERK', '1982-01-23', 7782, 1300, NULL, 10);
-- 7.Question
-- i. Write a query to display ename and job for all the employee with their half term salary.
SELECT ENAME, JOB, SAL / 2 AS HALF_SALARY
FROM employees;
-- Write a query to display all the details of
-- the employees along with an annual bonus
-- of 2000.
SELECT *, 2000 AS ANNUAL_BONUS
FROM emp;
-- Write a query to display ename and salary with
-- a hike of 10%.
SELECT ENAME, SAL, SAL * 1.1 AS SALARY_WITH_HIKE
FROM emp;
-- Write a query to display ename and salary with deduction of 25%."
SELECT ENAME, SAL, SAL * 0.75 AS SALARY_WITH_DEDUCTION
FROM emp;
-- 8. question-
-- Write a query to display name and hire date of
-- the employees if the employees were hired during 1982 .
SELECT ENAME, HIREDATE
FROM emp
WHERE YEAR(HIREDATE) = 1982;
-- Write a query to display name of the employee who gets salary as well
-- as commission .
SELECT ENAME
FROM emp
WHERE COMM IS NOT NULL;
-- Write a query to display name of the employee
-- of employee has character 'A' as the second character in the name
SELECT ENAME
FROM emp
WHERE ENAME LIKE '_A%';
-- Write a query to display avg salary needed to pay all the employees in each department excluding
the employees of deptno 20.
SELECT DEPTNO, AVG(SAL) AS AVG_SALARY
FROM emp
WHERE DEPTNO <> 20
GROUP BY DEPTNO;
-- Write a query to display number of employees
-- having character 'a' in their names in
-- each job
SELECT JOB, COUNT(*) AS NUM_EMPLOYEES
FROM emp
WHERE LOWER(ENAME) LIKE '%a%'
GROUP BY JOB;
-- Write a query to display maximum salaries
-- given to an employee working in each dept
SELECT DEPTNO, MAX(SAL) AS MAX_SALARY
FROM emp
GROUP BY DEPTNO;
-- Write a query to display ename and job of all
-- the employees working in the same designation as james
SELECT ENAME, JOB
FROM emp
WHERE JOB = (SELECT JOB FROM emp WHERE ENAME = 'JAMES');
-- 9. question
-- Write a query to display ename and hiredate of the employees who's name end’s with 's' and
hired after james
SELECT ENAME, HIREDATE
FROM emp
WHERE ENAME LIKE '%s'
AND HIREDATE > (SELECT HIREDATE FROM emp WHERE ENAME = 'JAMES');
OUTPUT-
7 .i)
7 .ii)
7.iii)
7.iv)
8.i)
8.ii)
8.iii)
8.iv)
9.i)
9.ii)
9.iii)
9.iv)
9.v)