Write a program to String concatenation with primitive data type values


This is a Java program that demonstrates the use of primitive data types and strings. The program declares several variables of different primitive data types, including an integer (age), a double-precision floating-point number (wei), a character (gen), and two boolean values (isMarried and isQualified).

The program also declares a string variable called name and initializes it with the value "Ram Kumar". The program then uses System.out.println() statements to print out the values of the variables. For example, the program prints out whether isMarried and isQualified are true or false, and it prints out name, age, gen, and wei along with descriptive strings.

Source Code

public class Primitive_Datatype
{
	public static void main(String[] args)
	{
		String res = null;
		String name = "Ram Kumar";
		int age = 29;
		double wei = 77.15;
		char gen = 'M';
		boolean isMarried = true;
		boolean isQualified = false;
 
		System.out.println( "isMarried : " + isMarried);
		System.out.println("isQualified : " + isQualified);
		System.out.println( name + " is " + age + " years old ");
		System.out.println( "His gender is : " + gen);
		System.out.println( name + " weight is " + wei + " kg.");
	}
}
 

Output

isMarried : true
isQualified : false
Ram Kumar is 29 years old
His gender is : M
Ram Kumar weight is 77.15 kg.

Example Programs