Java Input and Output - Long Answers

Understanding Java Input and Output

Explain the use of the Scanner class in Java. How does it work for different data types?

Describe the difference between System.out.print() and System.out.println(). Provide examples.

What is the purpose of the printf() method in Java? How does it differ from print() and println()?

How do the next() and nextLine() methods of the Scanner class differ in Java?

Explain how you can read and display different primitive data types (e.g., int, double, char) using Java input and output methods.