0% found this document useful (0 votes)
4 views9 pages

Java Session 4

Uploaded by

halkar Rachappa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views9 pages

Java Session 4

Uploaded by

halkar Rachappa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Paper Title: Java programming

Programme BCA
Subject Computer Science
Course 24MJBCA3L1
Code
Semester III
University Vijayanagara Sri Krishnadevaraya University, Ballari
(VSKUB)
Created by Dr. Halkar Rachappa
Session 4
Variables
• A variable is a named memory location
capable of storing data
• As we have already seen, object variables
refer to objects, which are created by
instantiating classes with the new operator
• We can also store data in simple variables,
which represent data only, without any
associated methods
Data declaration syntax
• The syntax for the declaration of a variable is:
Data type identifier;

• “data type” may be the name of a class, as we


have seen, or may be one of the simple types,
which we’ll see in a moment
• “identifier” is a legal Java identifier; the rules for
simple variable identifiers are the same as those
for object identifiers
Assignment statements
• We can store a value in a variable using an
assignment statement
• Assignment statement syntax:
variableName = expression;
• variableName must be the name of a declared
variable
• expression must evaluate to an appropriate value
for storage within the type of variable specified
Operators in Java
Introduction
• Operators are special symbols used to perform
operations on variables and values.

• Java supports various types of operators.


Types of Java Operators

• Arithmetic Operators
• Relational (Comparison) Operators
• Logical Operators
• Assignment Operators
• Unary Operators
• Bitwise Operators
• Ternary Operator
Arithmetic Operators

• + (Addition)
• - (Subtraction)
• * (Multiplication)
• / (Division)
• % (Modulus)
Example:
int a = 10, b = 3;
System.out.println(a + b); // 13
Relational Operators & Logical Operators

Relational Operators
 ==, !=, >, <, >=, <=
Example:
System.out.println(10 > 5); // true
Logical Operators

&& (AND)
• || (OR)
• ! (NOT)
Example:
System.out.println(true && false); // false
Thank you

You might also like