Posts

Write a program to perform all String class and StringBuffer class operation.

Image
  AIM: Write a program to perform all String class and StringBuffer class operation. CODE: (String) public class string{  public static void main(String args[]){             //string constructor             char []s1={'K','H','U','S','H','I'};             String s2=new String(s1);             System.out.println("\n"+s2+" - String constructor\n");               //string constructor with index number and number of chars             String s3=new String(s1,2,4);             System.out.println(s3+" - string constructor with index number and number of chars \n");       ...

Write a program in Java to multiply two matrix.

Image
  AIM:    Write a program in Java to multiply two matrix.   CODE: import java.util.Scanner; public class p10 {     public static void main(String args[])     {         Scanner readme = new Scanner(System.in);         int[][] n1 = new int[3][3];         int[][] n2 = new int[3][3];         int[][] ans = new int[3][3];         System.out.println("Enter the elements for 1st matrix \n");         for (int i = 0; i < 3; i++)         {             for (int j = 0; j < 3; j++)             {            ...

Write a Java Program with class Rectangle having instance variable width, length, area and colour. Create methods like setData() and area().Create two object of Rectangle and compare their area and colour. If area and colour both are the same for the objects then display “Matching Rectangles”, otherwise display “Non matching Rectangle”.

Image
  AIM:  Write a Java Program with class Rectangle having instance variable width, length, area and colour. Create methods like setData() and area().Create two objects of Rectangle and compare their area and colour. If area and colour both are the same for the objects then display “Matching Rectangles”, otherwise display “Non matching Rectangle”.   CODE: import java.util.Scanner; class Rectangle { int width,length,area; String colour;             void setData(int w,int l,String c) {               width =w;                          length=l;               colour=c;             }       ...

Create a class Cuboid having default and parameterized constructors. Calculate volume for three objects of class Cuboid instantiated using default and parameterized constructor respectively.

Image
  AIM:  Create a class Cuboid having default and parameterized constructors. Calculate volume for three objects of class Cuboid instantiated using default and parameterized constructor respectively.   CODE: import java.util.Scanner; public class Cuboid{             int length,width,height,volume;                         Cuboid(){                         length=1;                         width=1;                         height=1;    ...