Venkata Sai has Published 72 Answers

Program for subtracting two matrices.

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

To subtract two matrices −Create an empty matrix.At each position in the new matrix, assign the difference of the values in the same position of the given two matrices i.e. if A[i][j] and B[i][j] are the two given matrices then, the value of c[i][j] should be A[i][j] - B[i][j].Example Live Demopublic ... Read More

Program to print Sum Triangle of an array.

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

To generate a sum triangle of a given arrayGet the elements of the array from the user say, myArray[n].Create a two dimensional array say, result[n][n].Store the contents of the given array in the first row from bottom of the 2D array.result[n][i] = myArray[i].Now, from the second row of the 2D ... Read More

Program for printing array in Pendulum Arrangement.

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

To arrange elements of the array following pendulum arrangement.Sort the given array, create an empty array to store the result.Store the 0th element in a variable say temp.Store the element at index 1 in the sorted array in (mid+1)st position of the resultant array, and the next element int the ... Read More

Java program to print a given matrix in Spiral Form.

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

Following is a Java program to print the spiral form of a given matrix.Example Live Demopublic class PrintMatrixInSpiralForm {    public static void main(String args[]){       int a[][]={{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};       int w = 0;       int x = ... Read More

Program to print a matrix in Diagonal Pattern.

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

Following is the Java program to print diagonal pattern of a given matrix.Example Live Demopublic class DiagonalMatrix {    public static void main(String args[]){       int a[][]={{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};       int rows = a.length;       int columns = a[0].length; ... Read More

Program for converting Alternate characters of a string to Upper Case.

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

You can convert a character to upper case using the toUpperCase() method of the character class.ExampleFollowing program converts alternate characters of a string to Upper Case. Live Demoimport java.util.Scanner; public class UpperCase {    public static void main(String[] args) {       Scanner sc = new Scanner(System.in);       ... Read More

What is the need of wrapper classes in Java?

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

In java.lang package you can find a set of classes which wraps a primitive variable with in their object these are known as wrapper classes. Following is the list of primitive datatypes and their respective classes −Primitive datatypeWrapper classcharCharacterbyteByteshortShortintIntegerlongLongfloatFloatdoubleDoublebooleanBooleanExample Live Demopublic class Sample { public static void main ... Read More

What are Transient variables in Java? Explain.

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

In Java, serialization is a concept using which we can write the state of an object into a byte stream so that we can transfer it over the network (using technologies like JPA and RMI).While serializing an object of a class, if you want JVM to neglect a particular instance ... Read More

What is type conversion in java?

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

Java provides various datatypes to store various data values. It provides 7 primitive datatypes (stores single values) as listed below −boolean − Stores 1-bit value representing true or, false.byte − Stores twos compliment integer up to 8 bits.char − Stores a Unicode character value up to 16 bits.short − Stores ... Read More

Write a program to convert an array to String in Java?

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

The Arrays class of the java.util package provides a method named toString() this method accepts an array value (of any type) and returns a String.ExampleFollowing Java program accepts various arrays from the user, converts them into String values and prints the results. Live Demoimport java.util.Arrays; import java.util.Scanner; public class ObjectArrayToStringArray {    public ... Read More

Advertisements