An Overview

All the necessary study material for b-tech students.

What we have to offer you.

Codes,Syllabus,Study material,Lab manuals,Assignments and many more . . .

Surfing becomes easy.

You can have any material from our website and post your valuable comments for further improvement.

Get the latest techno news

Get yourself updated with this fast changing dynamic world and all the changes in b-tech pattern.

All the best resources for you.

We have done our level best to provide you with the best of the degree and thus this site is devoted to b-tech exclusively.

Showing posts with label JAVA Practical FIle. Show all posts
Showing posts with label JAVA Practical FIle. Show all posts

4 October 2013

JAVA Practical File (Btech)

AIM:- Write a program in JAVA to demonstrate constructor use.

Program:-


class Test
{
int x,y;
Test()
{
x=y=0;
}
Test(int m )
{
x=y=m;
}
Test(int x, int y)
{
this.x=x;
this.y=y;
}
void sum()
{
int c=x+y;
System.out.println("Sum of two numbers is"+" "+c);
}
}
class Test3
{
public static void main (String args [])
{
Test t1=new Test();
Test t2=new Test(40);
Test t3=new Test(30,30);
t1.sum();
t2.sum();
t3.sum();
}
}


Output:-  Sum of two numbers is 0
               Sum of two numbers is 80

               Sum of two numbers is 60


JAVA Practical File (Btech)

AIM:- Write a program in JAVA which is initialized through object and current object.

Program:-


class Test
{
int x,y;
void getData(int x,int y)
{
this.x=x;
this.y=y;
}
int sum()
{
return (x+y);
}
}
class Test2
{
public static void main (String args [])
{
Test t=new Test();
t.getData(10,30);
int c=t.sum();
System.out.println("Sum of two numbers is"+" "+c);
}
}


Output:-  Sum of two numbers is 40

JAVA Practical File (Btech)

AIM:- Write a program in JAVA which is initialized through object and current object.

Program:-


  class Test
{
int x,y;
}

class Test1
{
public static void main (String args[])
{
Test t = new Test();
t.x= 10;
t.y= 20;
int c= t.x + t.y;
System.out.println("Sum of two numbers is"+ " " +c);
}
}

Output:- The sum of two numbers is 30