0% found this document useful (0 votes)
37 views30 pages

Essentials of Information and Technology File: Submittedto: Submittedby

Here is a program to implement command line arguments in Java: ```java public class CommandLineArgs { public static void main(String[] args) { // Print out all command line arguments for(String arg : args) { System.out.println(arg); } // Check for a specific argument if(args.length > 0 && args[0].equals("hello")) { System.out.println("Hello argument detected"); } // Sum all integer arguments int sum = 0; for(String arg : args) { try { sum += Integer.parseInt(arg); } catch (NumberFormatException e) { // not an integer,

Uploaded by

SK Kashyap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views30 pages

Essentials of Information and Technology File: Submittedto: Submittedby

Here is a program to implement command line arguments in Java: ```java public class CommandLineArgs { public static void main(String[] args) { // Print out all command line arguments for(String arg : args) { System.out.println(arg); } // Check for a specific argument if(args.length > 0 && args[0].equals("hello")) { System.out.println("Hello argument detected"); } // Sum all integer arguments int sum = 0; for(String arg : args) { try { sum += Integer.parseInt(arg); } catch (NumberFormatException e) { // not an integer,

Uploaded by

SK Kashyap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 30

ESSENTIALS OF

INFORMATION AND
TECHNOLOGY
FILE

SubmittedTo: SubmittedBy:
Mrs.SHIKHA CHAUDHARY BHAVESH KASHYAP
Asst. Prof (CSE) CSE ‘A’ (4TH SEM)
251702067
INDEX

S.NO PROGRAM NAME SIGNATURE


1. Write the queries for Data Definition (DDL)
and Data Manipulation (DML) in RDBMS

2. Implement SQL queries for sub-queries and


set Operations.
3. To study SQL queries for Join Operation.
4. To study SQL queries for Views.
5. Implement binary search in raptor.
6. Implement bubble sort in raptor.
7. Implement swapping in raptor.
8. Write a Program to implement Fibonacci
series in java.
9. Write a Program to implement inheritance in
java.
10. Write a Program to implement overloading in
java.
11. Write a Program to implement command line
arguments in java.
12. Write a Program to implement static methods
in java.
PROGRAM NO. – 1
AIM : Write the queries for Data Definition (DDL) and Data Manipulation (DML) in
RDBMS
Data Definition Language(DDL)

Create Drop Alter


Truncate Comment Rename
Data Manipulation Language(DML)

Select Insert
Update Delete
1 Create Table Salesman and Customer

mysql>Create table Salesman(ID int,Name varchar(50),Age int,Address varchar(50),Salary int);


mysql>Create table Customer(ID int,Name varchar(50),Age int,Address varchar(50),Salary int);

2 Insert Data into Table Salesman and Customer

mysql>insert into Salesman values(101,'Shubham',20,'Ambala Cantt',50000);


mysql>insert into Salesman values(102,'Ashish',20,'Kurukshetra',40000);
mysql>insert into Customer values(1001,'Gambhir',21,'Ambala Cantt',60000);
mysql>insert into Customer values(1002,'Vikrant',21,'Kurukshetra',60000);
3 Show Data from Table Salesman and Customer mysql>Select
*from Salesman;

mysql>Select *from Customer;

4 Update Table Salesman set Salary 100000 where ID=101


mysql>Update Salesman set Salary=100000 where ID=101;
5 Alter Table Salesman modify Datatype of ID int to varchar(10) in table
mysql>Alter table Salesman MODIFY COLUMN ID varchar(10);

6 Rename Table Customer to Customers mysql>Alter table


Customer RENAME to Customers;

7 Comment Comand in table Customers mysql>Select Name


/*Age*/, Salary from Customers;
8 Delete Information from table Customers of ID=1005
mysql>Delete from Customers where ID=1005;

Create Another Table Demo

9 Truncate Table Demo mysql>Truncate table Demo;

10 Drop table Demo mysql> Drop table Demo;


PROGRAM NO. - 2
Aim : Implement SQL Queries For sub-Queries and Set Operations in RDBMS
1 Sub-Query with the SELECT Statement

mysql> Select *from Customers where ID IN (Select ID from Customers where Salary>50000);

2 Sub-Query with the INSERT Statement

mysql> Insert into Customer Select *from Customers where ID IN(Select ID from Customers);

3 Sub-Query with the UPDATE Statement

mysql> Update Customers set Salary=Salary*0.25 where Age IN (Select Age from Customer
where Age>20);
4 Sub-Query with the DELETE Statement

mysql>Delete from Customers where Age IN (Select Age from Customer where Age>20);

Set Operations

Union Intersection
OrderBy Minus

5 Union of table Customers and Salesman

mysql> Select *from Salesman where Age=20 UNION Select * from Customer where Age=20;

6 Intersection of table Customers and Salesman

mysql> Select *from Salesman,Customers where Salesman.Age=Customers.Age;


7 Minus of table Customers and Salesman

mysql> Select *from Salesman,Customers where Salesman.Age!=Customers.Age;

8 OrderBy of table Customers and Salesman

mysql> Select *from Salesman where Age=20 UNION Select * from Customer where Age=20
ORDER BY 2;
PROGRAM NO. - 3
Aim : To study SQL Queries for Join operations in RDBMS
Join Operations

Inner Join Cartesian Join Self Join


Outer Join( Left Join ,, Right Join ,, Full Join)
1 Inner Join Operation on table Customers and Salesman

mysql> Select Salesman.ID,Salesman.Name from Salesman INNER JOIN Customers ON


Salesman.Age=Customers.Age;

2 Outer Join Operation on table Customers and Salesman


• Left Joinmysql> Select Salesman.ID,Customers.Name from Salesman LEFT JOIN
Customers ON Salesman.Age=Customers.Age;

• Right Join mysql> Select Salesman.ID,Customers.Name from Salesman RIGHT JOIN


Customers ON Salesman.Age=Customers.Age;
• Full Join mysql> Select ID, Name from Salesman UNION ALL Select ID,Name from
Customers;

3 Cartesin Join Operation on table Customers and Salesmanmysql>


Select ID,Name,ProductNo,Product from Customer2,Salesman;

4 Self Join Operation on table Customers and Salesman


mysql> Select Customers.Id AS CustomerID, Salesman.ID AS SalesmanID from Customers,Salesman
where Customers.Age=Salesman.Age;
PROGRAM NO. -4
Aim : To study SQL Queries for View Operations in RDBMS

Commands for View

Create Drop
Update Delete
1 Create A view of table Salesman

mysql> Create view Sales AS SELECT ID,Name,Salary from Salesman;

2 Update A view of table Salesman

mysql> Update Sales set Name='Gambhir' where ID=105;

3 Delete A view of table Salesman


mysql> Delete from Sales where ID=105;
4 Drop A view of table Salesman mysql> Drop view Sales;
PROGRAM No. -5

Aim: Implement binary search in raptor.


A

OUTPUT:
PROGRAM NO. - 6
AIM: Implement bubble sort in raptor.

Z X Y
X Y
Z

C A

B
A

C B
OUTPUT:
PROGRAM NO. - 7
Aim: Implement swapping in raptor.
OUTPUT:
PROGRAM NO. - 8
AIM: Write a Program to implement Fibonacci series in java.

import java.util.Scanner;
public class NewClass {
public static void main(String[] args)
{ int ch=1;
while(ch==1){
int a=0,b=1;
Scanner in=new Scanner(System.in);
System.out.println("Enter the number of elements ");
int n=in.nextInt();
if(n==0)
System.out.println("Enetr a valid number (you entered 0)");
if(n==1)
{ System.out.print(a+" "); }
else {
System.out.print(a+" "+b); }
n=n-2;
for(int i=0;i<n;i++)
{ int c=a+b;
a=b;
b=c;
System.out.print(" "+c); }
System.out.println("\nEnetr 1 to repeat and anything else to exit");
ch=in.nextInt(); } } }
OUTPUT:
PROGRAM NO. - 9
AIM: Write a Program to implement inheritance in java.
package inheritance;
import java.util.Scanner;
class Box {
private double width;
private double height;
private double depth;
Box(double w, double h, double d) {
width = w;
height = h;
depth = d;}
Box() {
width = -1;
depth = -1;
height = -1; }
Box(double len) {
width = height = depth = len; }
double volume() {
return width * height * depth;
}}
class BoxWeight extends Box {
double weight;
BoxWeight(double w, double h, double d, double m) {
super(w, h, d);
weight = m;
}
BoxWeight() {
super();
weight = -1;
}
BoxWeight(double len, double m) {
super(len);
weight = m;
}
}
public class Inheritance {
public static void main(String[] args) {
double l,b,h,m;
Scanner sc = new Scanner(System.in);
System.out.println("Enter length , width and height:");
l = sc.nextDouble();
b = sc.nextDouble();
h = sc.nextDouble();
System.out.println("Enter weight of cuboid: ");
m = sc.nextDouble();
BoxWeight mybox1 = new BoxWeight(l,b,h,m);
double vol;
vol = mybox1.volume();
System.out.println("Volume of myBox1 is : " + vol);
System.out.println("Weight of myBox1 is : " + mybox1.weight);
System.out.println("");

System.out.println("Enter length of cube: ");


l = sc.nextDouble();
System.out.println("Enter weight of cube: ");
m = sc.nextDouble();

BoxWeight mycube = new BoxWeight(l, m);

vol = mycube.volume();
System.out.println("Volume of mycube is : " + vol);
System.out.println("Weight of mycube is : " + mycube.weight);
System.out.println("");

}
}
OUTPUT:
PROGRAM NO. - 10
AIM: Write a Program to implement overloading in java.
public class NewClass {
public static void main(String[] args)
{
System.out.println("5+6="+sum(5,6));
System.out.println("5+6+7="+sum(5,6,7));
System.out.println("5+6+7+8="+sum(5,6,7,8));
}
private static int sum(int i, int j) {
return i+j;
}
private static int sum(int i, int j, int k) {
return i+j+k;
}
}

OUTPUT:
PROGRAM NO. - 11
AIM: Write a Program to implement command line arguments in java.

public class NewClass {


public static void main(String[] args)
{
for(String s:args)
{
System.out.println(s);
}
}
}

OUTPUT:
PROGRAM NO. - 12
AIM: Write a Program to implement static methods in java.
public class NewClass {
public static void main(String[] args) {
display();
NewClass t = new NewClass ();
t.show();
}
static void display() {
System.out.println("This is static method.");
}
void show(){
System.out.println("This is non static method");
}
}

OUTPUT:

You might also like