0% found this document useful (0 votes)
11 views2 pages

Java Input, Output, Data Types, Operators

The document provides an overview of input and output in Java, explaining how to use the Scanner class for user input and various methods for displaying output. It also covers data types, including primitive and reference types, and introduces operators used for arithmetic, comparison, and logical operations. Examples are provided for each concept to illustrate their usage in Java programming.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Java Input, Output, Data Types, Operators

The document provides an overview of input and output in Java, explaining how to use the Scanner class for user input and various methods for displaying output. It also covers data types, including primitive and reference types, and introduces operators used for arithmetic, comparison, and logical operations. Examples are provided for each concept to illustrate their usage in Java programming.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Java Presentation - Objective 3

Input in Java
Definition:
Input means getting data from the user.

How:
Use the Scanner class from [Link] to read user input.

Example:
import [Link];
Scanner scan = new Scanner([Link]);
[Link]("Enter your name: ");
String name = [Link]();
[Link]("Hello " + name);

Meaning of Scanner:
Scanner reads data typed by the user (like numbers or words).

Output in Java
Definition:
Output means displaying information to the user.

Ways to Output:

1. [Link]() – prints text with a new line


Example:
[Link]("Hello!");

2. [Link]() – prints text without a new line


Example:
[Link]("Hello ");

3. [Link]() – prints formatted text


Example:
[Link]("Age: %d", 18);

Data Types in Java


Definition:
Data types tell Java what kind of value a variable holds.

Primitive Types:
int – whole numbers
double – decimals
char – single character
boolean – true/false

Reference Type:
String – group of characters (text)

Operators in Java
Definition:
Operators perform actions on values or variables.

Types (with examples):


Arithmetic: +, -, *, /, % → int sum = 5 + 3;
Comparison: ==, !=, >, < → x > y
Logical:
&& (AND) → true if both are true
|| (OR) → true if one is true
! (NOT) → reverses value

Example:
if (x > 5 && y < 10) {
[Link]("Both conditions true");
}

You might also like