Write a Java program to print message using class


This is a Java program that defines a class called Welcome with a method print_msg(). The print_msg() method simply prints a message "Welcome Java Exercise" to the console.

The program also contains the main() method, which creates an instance of the Welcome class and calls its print_msg() method to print the welcome message to the console.

When the program is run, it will print the message "Welcome Java Exercise" to the console.

Source Code

import java.util.*;
class Welcome
{
	public void print_msg()
	{
		System.out.println("Welcome Java Exercise");
	}
 
	public static void main(String s[])
	{
		Welcome obj = new Welcome();
		obj.print_msg();
	}
}

Output

Welcome Java Exercise