Practical File of Essentials of Information Technology (CSE-314N)

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 16

Roll no.

-87175101

PRACTICAL FILE OF
ESSENTIALS OF INFORMATION
TECHNOLOGY
(CSE-314N)

Submitted to: Submitted by:


Mr. Vedprakash Abhishek
HOD in CSE Deptt. CSE 6th sem.
Roll no. 87175101

Department of Computer science and Engineering


Roll no.-87175101

State Institute of Engineering and Technology


(Nilokheri)
OUTPUT:-
Roll no.-87175101

PROGRAM:-1
AIM:-Write a program of insertion sortin java using classes and objects.
package insertion_sort;
public class Insertion_sort {
public static void main(String[] args)
{
int[] a = {12,22,5,13,9};
System.out.println("Before Insertion sort");
printArray(a);
insertionsort(a);
System.out.println("After insertion sort");
printArray(a);
}
public static void insertionsort(intarr[])
{
int n = arr.length;
for(inti =1;i<n;i++)
{
System.out.println("Sort pass number"+(i));
int key=arr[i];
int j = i-1;
while((j>-1 &&arr[j] < key))
{
arr[j+1] = arr[j];
j--;
}
arr[j+1] = key;
printArray(arr);
}
}
public static void printArray(int[] array)
{
for(inti =0; i<array.length; i++)
{
System.out.print(array[i] + ",");
}
System.out.println();
Roll no.-87175101

OUTPUT:-
Roll no.-87175101

PROGRAM-2(A)
AIM:-Write a program in java implementing theparameter passing
techniques.
Call by value:-
public class PassByValue
{
public static void swap(intx,int y)
{
int temp=x;
x=y;
y=temp;
System.out.println("x1="+x);
System.out.println("y1="+y);
}
public static void main(String[] args)
{
int x=45;
int y=36;
swap(x,y);
System.out.println("x2="+x);
System.out.println("y2="+y);
}
}
Roll no.-87175101

OUTPUT:-
Roll no.-87175101

PROGRAM-2(B)

Call by reference:-

public class ByReference


{
public static void swap(String s1,String s2)
{
String temp=s1;
s1=s2;
s2=temp;
System.out.println("s1(A)="+s1);
System.out.println("s2(A)="+s2);
}
public static void main(String[] args)
{
String s1="SIET";
String s2="STUDENTS";
swap(s1,s2);
System.out.println("s1(B)="+s1);
System.out.println("s2(B)="+s2);
}
}
Roll no.-87175101

OUTPUT:-
Roll no.-87175101

PRACTICAL:-3
AIM:-Write a program in java implementing the multilevel inheritance.
package MultilevelInheritance;
class Multimain{
public static void main(String args[]){
S3 obj=new S3();
obj.display();
}
}
public class MultilevelInheritance
{
protected String str;
MultilevelInheritance(){
str="Btech-";
}
}
class S1 extends MultilevelInheritance{
S1(){
str=str.concat("CSE");
}
}
class S2 extends S1{
S2(){
str=str.concat("3rd Year");
}
}
class S3 extends S2{
S3(){
str=str.concat("Java Program");
}
void display(){
System.out.println(str);
}
}
Roll no.-87175101

OUTPUT:-
Roll no.-87175101

PROGRAM-4
AIM:-Write a program in java implementing the interface.
interface Itemconstant
{
int code = 1001;
String name = "fan";
}
interface Item extends Itemconstant
{
void display();
}
interface Area
{
final static float pi = 3.14F;
float compute(float x, float y);
}
class rectangle implements Area {
public float compute(float x, float y)
{
return (x * y);
}
}
class circle implements Area {
public float compute(float x, float y)
{
return (pi * x * x);
}
}
class Multiple {
public static void main(String[] args) {
rectangle rect = new rectangle();
circle cir = new circle();
Area area;
area = rect;
System.out.println("Area of rectangle=" + area.compute(10, 20));
area = cir;
System.out.println("Area of circle=" + area.compute(10, 0));
}
}
Roll no.-87175101

OUTPUT:-
Roll no.-87175101

PROGRAM:-5
AIM:-Write a program in java implementing the method overloading.
class DisplayOverloading

public void disp(char c)

System.out.println(c);

public void disp(char c, intnum)

System.out.println(c + " "+num);

class Sample

public static void main(String args[])

DisplayOverloadingobj = new DisplayOverloading();

obj.disp('a');

obj.disp('a',10);

}
Roll no.-87175101

OUTPUT: -
Roll no.-87175101

PROGRAM:-6
AIM:-Write a program in java using user define package.

import myPack.*;

class PackageTest
{
public static void main(String args[])
{
HP obj1= new HP();
Dell obj = new Dell();
obj1.display();
obj.display();
}
}
package myPack;
public class HP
{
public void display()
{
System.out.println("HP Class");
}
}
package myPack;
public class Dell
{
public void display()
{
System.out.println("Dell Class");
}
}
Roll no.-87175101

You might also like