Day 2

You might also like

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

1 // Online Java Compiler

// Use this editor to write, compile and run your Java code online
import java.util.*;
class Hello
{
static int a=5,b=10;

public static void main(String[] args) {


System.out.println(a+" "+b);
}
}
2// Online Java Compiler
// Use this editor to write, compile and run your Java code online
import java.util.*;
class HelloWorld {
final int a=10;
public static void main(String[] args) {
HelloWorld h=new HelloWorld();
System.out.println(h.a);
}
}
3
import java.util.*;
class Suresh
{
int a,b;

void input(int a,int b)


{
this.a=a;
this.b=b;
}

}
class Main{
public static void main(String args[])
{
Suresh s=new Suresh();
s.input(10,20);
System.out.print(s.a+" "+s.b);
System.out.println();
Suresh s1=new Suresh();
s1.input(100,200);
System.out.print(s1.a+" "+s1.b);
}
}
4
import java.util.*;
class Suresh
{
int a,b;

Suresh()
{
a=5;b=6;
}

}
class Main{
public static void main(String args[])
{
Suresh s=new Suresh();
System.out.print(s.a+" "+s.b);
}
}
5
import java.util.*;
class Suresh
{
int x,y;

Suresh(int a,int b)
{
x=a;
y=b;
}

}
class Main{
public static void main(String args[])
{
Suresh s=new Suresh(10,20);
System.out.print(s.x+" "+s.y);
System.out.println();
Suresh s1=new Suresh(100,200);
System.out.print(s1.x+" "+s1.y);
}
}

You might also like