Thursday 24 November 2016

Thread program with try catch in core java example

public class Ar {


    public static void main(String[] args)

    {


        new x();


        try

        {

            for (int i = 5; i > 0; i--)

            {

                System.out.print("main thread" + i);

                Thread.sleep(1000);


            }

        } catch (InterruptedException e)

        {

            System.out.print(e);

        }

    }


}

Inheritance program in java

class a

{

    void fun()

    {

        System.out.println("hell0");

    }

}

class extends a

{

    void fun()

    {

        System.out.println("bye");

    }

}

class extends b

{
    void fun()

    {

        System.out.println("say no");

    }

}


class hello

{

    public static void main(String arg[])

    {

        a c = new b();

//a r;

        a a = new b();

        b b = new b();

//r=a;

//r.fun();

//r=b;

        b.fun();

        c.fun();

    }


}

Java program try catch example

class ex

{

    public static void main(String arg[])

    {

        try

        {

            int a = arg.length;

            System.out.println("a=" + a);

            int b = 25 / a;

            int c[] = {1};

            c[20] = 50;

        } catch (ArithmeticException e)

        {

            System.out.println("exception " + e.getMessage());

        } catch (ArrayIndexOutOfBoundsm Exception e)

        {

            System.out.println("exception " + e);

        }

    }
}

C# program small application create in netbean
















 using System;

    using System.Collections.Generic;

        using System.ComponentModel;

        using System.Data;

        using System.Drawing;

        using System.Linq;

        using System.Text;

        using System.Windows.Forms;


        namespace groupbox

        {

        publicpartialclassForm1:Form

        {

public Form1()

        {

        InitializeComponent();

        }


        privatevoid checkBox5_CheckedChanged(object sender,

        EventArgs e)

        {

        if(checkBox5.Checked)

        {

        groupBox1.Visible=true;

        button1.Visible=true;

        checkedListBox1.Visible=true;

        button2.Visible=true;

        }

        else

        {

        groupBox1.Visible=false;

        button1.Visible=false;

        checkedListBox1.Visible=false;

        button2.Visible=false;

        }

        }


        privatevoid button1_Click(object sender,EventArgs e)

        {

        String str="";

        if(checkBox1.Checked)

        {

        str+=checkBox1.Text+"\n";

        }

        if(checkBox2.Checked)

        {

        str+=checkBox2.Text+"\n";

        }

        if(checkBox3.Checked)

        {

        str+=checkBox3.Text+"\n";

        }

        if(checkBox4.Checked)

        {

        str+=checkBox4.Text+"\n";

        }

        MessageBox.Show(str);

        }


        privatevoid button2_Click(object sender,EventArgs e)

        {

        String str="";

        CheckedListBox.CheckedItemCollection con=checkedListBox1.CheckedItems;

        for(int i=0;i<con.Count;i++)

        {


        str+=con[i].ToString()+",";


        }

        if(str!="")

        {

        str=str.Substring(0,str.Length-1);

        MessageBox.Show(str);

        }

        }

        }

        }

Create java program of simple array

1.create file in notepad with dd.java



 output