You are on page 1of 11

Page |1

Shri Shivaji Education Society, Amravati’s

Shri Shivaji College of Arts, Commerce &


Science, Akola.
NAAC Re-accredited with ‘A’ Grade with CGPA 3.24

UGC Status of ‘College with Potential for Excellence’

UG Department of Computer Science


&
Information Technology
Certificate
This is to certify that Mr. Aditya Gajanan Khirekar has satisfactorily completed
the Practical in the subject computer science for the class B.Sc-III (Sem-VI) having
Batch: CES in Computer-lab of this college in the Academic session 2020-2021.

1) -------------------------------

2) -------------------------------

Sign of Asso. Prof./Asst. Prof.

Date: / /2021 Head


Place: Akola Dept. of Computer Science& IT
Page |2

Computer science
&
Informationtechnology
2020-2021

Name: Aditya Gajanan Khirekar

Class : B.Sc-III (sem-VI)

Batch : CES

Subject: computer science

Id No : 51983
Page |3

Shri Shivaji College of Arts, Commerce &


Science, Akola.
NAAC Re-accredited with ‘A’ Grade with CGPA 3.24

UGC Status of ‘College with Potential for Excellence’

Java

programming
Page |4

INDEX
Sr. Page Remark
Name of Program
No. No. /Sign

1 The Use of Any four built in exception. 5

2 Java AWT list with ActionListener 9


Page |5

Program No.1
Aim : The Use of Any four built in exception.
Name: Aditya G. Khirekar
Roll ID:- 51983
Class: B.Sc-III(sem-VI) Batch:-CES

1. Arithmetic exception : It is thrown when an exceptional condition has


occurred in an arithmetic operation.
class ArithmeticException_Demo

public static void main(String args[])

    {

        try {

            int a = 30, b = 0;

            int c = a / b; // cannot divide by zero

            System.out.println("Result = " + c);

        }

        catch (ArithmeticException e) {

            System.out.println("Can't divide a number by 0");

        }

    }

}
Page |6

Output:
Can't divide a number by 0

2. ArrayIndexOutOfBounds Exception : It is thrown to indicate that an


array has been accessed with an illegal index. The index is either
negative or greater than or equal to the size of the array.

class ArrayIndexOutOfBound_Demo

public static void main(String args[])

    {

        try {

            int a[] = new int[5];

            a[6] = 9; // accessing 7th element in an array of

            // size 5

        }

        catch (ArrayIndexOutOfBoundsException e) {

            System.out.println("Array Index is Out Of Bounds");

        }

    }

}
Page |7

Output:

Array Index is Out Of Bounds

3. ClassNotFoundException : This Exception is raised when we try to access


a class whose definition is not found.
class Bishal

} class Geeks {

} class MyClass {

public static void main(String[] args)

    {

        Object o = class.forName(args[0]).newInstance();

        System.out.println("Class created for" + o.getClass().getName());

    }

Output:

ClassNotFoundException
Page |8

4. FileNotFoundException : This Exception is raised when a file is not


accessible or does not open.
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
class File_notFound_Demo
{

public static void main(String args[])


    {
        try {

            // Following file does not exist


            File file = new File("E:// file.txt");

            FileReader fr = new FileReader(file);


        }
        catch (FileNotFoundException e) {
            System.out.println("File does not exist");
        }
    }
}

Output:
File does not exist
Page |9

Program No.2
Aim: Java AWT list with ActionListener
Name: Aditya G. Khirekar
Roll ID:- 51983
Class: B.Sc-III(sem-VI) Batch:-CES
Source code:
import java.awt.*;
public class ListExample
{
ListExample(){
Frame f= new Frame();
List l1=new List(5);
l1.setBounds(100,100, 75,75);
l1.add("Item 1");
l1.add("Item 2");
l1.add("Item 3");
l1.add("Item 4");
l1.add("Item 5");
f.add(l1);
f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String args[])
{
new ListExample();
}
}
P a g e | 10

Output:
P a g e | 11

You might also like