You are on page 1of 5

LAB-3

BASIC JAVA
• public class Test {

• public static void main(String arr[]) {

• int a=5;
• boolean b=true;
• char c='A';
• double d=34.25;

• System.out.println(a);

• System.out.println(b);
• System.out.println(c);
• System.out.println(d);
• }

• }
• public class test1 {

• public static void main(String[] args) {

• float a=(float)12.34;

• System.out.println(a);

• }

• }
• class Rectangle1
• {

• int l,b;
public class RectangleTest {
• public void display()
• {

• System.out.println("length="+l);
public static void main(String[]
• System.out.println("breadth="+b);
• }
args) {
• } Rectangle r=new Rectangle();
• public class Rectangle extends Rectangle1 {
r.setDimension(10, 30);

r.display();
• public int area()
• {
• return l*b;

• }
System.out.println("Area="+r.ar
• public void setDimension(int x,int y) ea());
• {


l=x;
b=y;
}
• }

}
• }
• public class test3 {

• int a,b;

• public test3(int a,int b)

• {
• this.a=a;
• this.b=b;
• System.out.println(" in two argument constructor");
• }

• public test3(int a)

• {

• this(a,10);

• System.out.println("it is one parameter construtor");


• }

• public test3()
• {
• this(2,3);

• System.out.println(" in defult constructor");


• }

• public void display()


• {
• System.out.println("a="+a);
• System.out.println("b="+b);
• }

• public static void main(String[] args) {

• test3 x =new test3();

• x.display();

• test3 y= new test3(10);


• y.display();

• test3 z =new test3(20,30);


• z.display();

• }

• }

You might also like