java programming

java program for Area and perimeter of rectangle and square using constructor overloading

/*Area and perimeter of rectangle and square using constructor overloading. Constructor overloading means there will be two or more constructor and the name of all constructors will be same only number of arguments will be different. when you pass arguments value in the constructor it matches the number of arguments value with the defined constructor …

java program for Area and perimeter of rectangle and square using constructor overloading Read More »

java program for finding Area of rectangle and square using constructor overloading

 /*Area and perimeter of rectangle and square using constructor overloading. Constructor overloading means there will be two or more constructor and the name of all constructors will be same only number of arguments will be different. when you pass arguments value in the constructor it matches the number of arguments value with the defined constructor …

java program for finding Area of rectangle and square using constructor overloading Read More »

java program of Box using constructor overloading

//Constructor overloading using Box for no parameter for one parameter and for all parameters.import java.io.*;import java.util.*;class MyBox{double length;double depth;double width;//Constructor called when all three dimesions are apecified. MyBox(double l,double d,double w){length = l;depth = d;width = w;}//Defining method to calculate vol.double vol1(){return length*width*depth;}//Constructor when no parameters is initialized.MyBox(){//-1 to indicate an uninitialized box.width=-1;depth=-1;length=-1;}//Defining method to …

java program of Box using constructor overloading Read More »

java program for box using constructor

//program for box using constructor import java.io.*;import java.util.*; class MyBox{    double length;    double breadth; MyBox(double l,double b){    length=l;    breadth=b;}    double vol(){        return length * breadth;    }}class Box{    public static void main(String args[]){    MyBox rectangle=new MyBox(10,20);    System.out.println(“vol is “+rectangle.vol());}}   OUTPUT-vol is 200.0

java program for printing binary right angled traingle

/*1 1 0  1 0 11 0 1 01 0 1 0 1*/ import java.io.*;import java.util.*; public class Binary_triangle {public static void main(String[] args) {                int num,row,coloumn;        System.out.println(“Enter the size of row”);        Scanner sc=new Scanner(System.in);        num=sc.nextInt();        for(row=1;row<num;row++)        {            for(coloumn=1;coloumn<=row;coloumn++)                System.out.print(coloumn % 2+”t”);                System.out.print(“n”);                }            }    }

java program to calculate area and volume using constructor

/*constructor is a special type of method in which the name of the method is same as the class and there is no return type constructor are used to initialize the value of data.*/ //Area and volume of cylinder using constructor.import java.io.*;import java.util.*;class Vol{double radius;double height;Vol(double r,double h){radius = r;height = h;}double vol(){return 3.14*radius*radius*height;}}class Area{   …

java program to calculate area and volume using constructor Read More »

java program for searching an element in the array and displaying index number as well

package arraysearch;import java.io.*;import java.util.*; public class Arraysearch {         public static void main(String[] args) {            int num,i,num2,flag=0;                System.out.println(“Enter the size of array”);                Scanner sc=new Scanner(System.in);                num=sc.nextInt();  …

java program for searching an element in the array and displaying index number as well Read More »

java program for sorting array using selection sort

package arraysort;import java.io.*;import java.util.*; public class Arraysort {     public static void main(String[] args) {          int num,i,j,temp;        System.out.println(“Enter the size of array”);        Scanner sc=new Scanner(System.in);        num=sc.nextInt();        System.out.println(“Enter elements in array one by one”);        int array[]=new …

java program for sorting array using selection sort Read More »

Open chat