Answer:
import java.util.Scanner;
public class Lab_Program
{
//declare the variable for scanner
static Scanner in=new Scanner(System.in);
//main method
public static void main(String[] args)
{
//declare the required variable
String str;
//prompt the user to enter a sample text
System.out.println("Enter a sample text: ");
//read the string
str=in.nextLine();
//display the string
System.out.println("You entered: "+str);
}
}