Professional Documents
Culture Documents
Programming with
Java(CT405-N)
Prof. Vimal Bhatt , Assistant
Professor
Computer Science & Engineering
Vidush Somany Institute of Technology & Research,Kadi
Chapter 1
Introduction to Java
Agenda 01 Basic of Java Programming
03 Control Structures
Looping, Methods,overloading,
04
Types of variables
Local variable
instance variable
static variable
Types of Variable
Local Variable Instance Variable
A variable declared inside the body of the method is A variable declared inside the class but outside the body of the
called local variable. You can use this variable only within method, is called an instance variable. It is not declared as static
that method and the other methods in the class aren't .
even aware that the variable exists. It is called an instance variable because its value is instance-
A local variable cannot be defined with "static" keyword. specific and is not shared among instances.
Output: 10
Output: This is a simple java program
10.0
Operators in Java
Unary postfix expr++ expr--
additive +-
equality == !=
bitwise exclusive OR ^
bitwise inclusive OR |
logical OR ||
Ternary ternary ?:
Output:22,21
Java Unary Operator Program
Java AND Operator Example: Logical && and Java OR Operator Example: Logical || and Bitwise |
Bitwise &
The logical || operator doesn't check the second
condition if the first condition is true. It checks the
The logical && operator doesn't check the second condition if the first second condition only if the first one is false.
condition is false. It checks the second condition only if the first one is The bitwise | operator always checks both
true. conditions whether first condition is true or false.
The bitwise & operator always checks both conditions whether first public class OperatorExample{
condition is true or false. public static void main(String args[]){
public class OperatorExample{ int a=10;
public static void main(String args[]){ int b=5;
int a=10; int c=20;
int b=5; System.out.println(a>b||a<c);//true || true = true
int c=20; System.out.println(a>b|a<c);//true | true = true
System.out.println(a<b&&a<c);//false && true = false //|| vs |
System.out.println(a<b&a<c);//false & true = false System.out.println(a>b||a++<c);//true || true = true
}} System.out.println(a);//
10 because second condition is not checked
System.out.println(a>b|a++<c);//true | true = true
System.out.println(a);//
11 because second condition is
Output: false, false checked
}}
Output:true,true,true,10,true,11
Java Assignment Operator Program
Output: 20
Output: 13,9,18,9
THANK YOU