0% found this document useful (0 votes)
15 views

Java File

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Java File

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

conttructor overloading

public class Box {


double width, height, depth;
int boxNo;

// constructor used when all dimensions and


// boxNo specified
Box(double w, double h, double d, int num)
{
width = w;
height = h;
depth = d;
boxNo = num;
}

// constructor used when no dimensions specified


Box()
{
// an empty box
width = height = depth = 0;
}

// constructor used when only boxNo specified


Box(int num)
{
// this() is used for calling the default
// constructor from parameterized constructor
this();

boxNo = num;
}

public static void main(String[] args)


{
// create box using only boxNo
Box box1 = new Box(1);

// getting initial width of box1


System.out.println(box1.width);
}
}

statement

public class {

int x = 50;
int y = 10;
if(x > y) {
System.out.println("Hello World");
else
system.out.println("beijesh");

}
loops

Class main
{
Public static void main(string[] args )
{
Int i=5;
// for printing
For(int i=0;i<5;i++)
System .out.println(“brijesh”);
}

while loop-------

class main
{
public static void main(string[] args )
{
int a=6;
while(a)
syatem.out.println("brijesh");
}

You might also like