.
Home About-us Privacy Policy Contact-us Services

Friday, October 16, 2015

Java - Constructor Program Example - Allprogramexample

By With No comments:
Constructor Program Example
class cube
{
int lenth;
int width;
int height;
cube()         //Constructor initilize
{
lenth=10;
width=20;
height=2;
}
int volume()
{
return(lenth*width*height);
}
}
class cons
{
public static void main(String aa[])
{
cube cc1=new cube();

int a=cc1.volume();
System.out.println("the volum of "+a);
}}



Read More

Java - Array Program Example - Allprogramexample

By With No comments:
Array Program Example - 
class array1
{
public static void main(String arg[])
{
int ar[][]={{3,5,7},{4,7,2}};
int n=ar.length;
System.out.println("The list of elements are");
for(int i=0;i<n;i++)
for (int j=0;j<n;j++)
System.out.println(ar[i][j]);
}
}

 
Read More

Java - Add the Two Number Program Example - Allprogramexample

By With No comments:
Add the Two Number Program
class add1
{
public static void main(String args[])
{
System.out.println("Addtion of two numbers");
int a=10;
int b=15;
int c=a+b;
System.out.println("result is "+c);
}


Output - 
25

 
Read More

Java - String Function Program Example - Allprogramexample

By With No comments:
String Function Example
class stringfun
{
public static void main(String[] args)
{
String s="cjsoftech";
String s2="iitsdpatiala";
String s3=s2.substring(2,5);
String s4=s.concat(s2);
int i;
int j;
System.out.println("hello "+s);
System.out.println("length of s "+s.length());
System.out.println("s2.subString(2,5) "+s3);
System.out.println("s2.charAt(2) "+s2.charAt(2));
i=s.compareTo(s2);
System.out.println("s.compareTo(s2) "+i);
System.out.println("concate  "+s4);
j=s.indexOf('o');
System.out.println("index of o "+j);
String s5=s.replace('s','S');
System.out.println("after replace "+s5);
String s6=s.toUpperCase();
System.out.println("s6 uppercase "+s6);
String s7=s6.toLowerCase();
System.out.println("s6 lowercase "+s7);
int m=123;
String s8=String.valueOf(m);
System.out.println("valueof "+s8);
}
}






Read More

Java - Final class program example - Allprogramexample

By With No comments:
final class rect
{
public void input1()
{
System.out.println("rect");
}
}

class box extends rect
{
public void input2()
    {
System.out.println("box");
}
}

class test
{
public static void main(String arg[])
{
box x=new box();
x.input1();
x.input2();
  }
  }




Read More

Java - factorial number example - Allprogramexample

By With No comments:
Factorial number example
class  fact
{
public static void main(String r[] )
{
int i=1,m=1,n;
n=Integer.parseInt(r[0]);
do
{
 m=m*i;
 i++;
}
while (i<=n);
System.out.println("Fact of "+n+"is ="+m);
}
}


Read More

Java - Bitwise Operator Example - Allprogramexample

By With No comments:
Bitwise Operator Example
class bitwise
{
 public static void main(String args[])
 {
  int a=22,b=10,and,or,comp,xor,rs,ls;
and=a&b;
or=a|b;
comp=~a;
xor=a^b;
rs=a<<2;
ls=a>>2;
System.out.println("and "+and);
System.out.println("or "+or);
System.out.println("comp "+comp);
System.out.println("xor "+xor);
System.out.println("rs "+rs);
System.out.println("ls "+ls);
}
}

Read More

In Java - Arithmatic Operator Example

By With No comments:
Arithmatic  Operator Example

class oper1
{
public static void main (String aa[])
{
int a=20;
int b=a*2;
int c=b-30;
int d=c/2;
System.out.println("Result of a is"+a);
System.out.println("Result of a is"+b);
System.out.println("Result of a is"+c);
System.out.println("Result of a is"+d);
}}

Output -
Result of a = 20
Result of b = 40
Result of c = 10
Result of d =5


Read More

java Hello world program example

By With No comments:
Helloo World Java program example

class helloo
{
public static void main(String arg[])
{
sytem.out.println("helloo java program ");
}
}

you can save this program in your computer drive with the extension of .java like helloo.java and compile with javac helloo.java when it compile and error free then you can run with simple java helloo.


Read More
Home About-us Privacy Policy Contact-us Services
Copyright © 2014 All Programs Examples | All Rights Reserved. Blogger Templates Download Blogger Templates