0% found this document useful (0 votes)
41 views

Java Programming: by Mr. Ssemujju Bernard 0781396066

This document discusses Java keywords, operators, and assignment operators. It lists common Java keywords like abstract, assert, boolean, etc. that cannot be used as variable names. It describes arithmetic, relational, logical, bitwise, and assignment operators. Examples are provided to demonstrate how assignment operators like += work in Java programs.

Uploaded by

Edwins kato
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Java Programming: by Mr. Ssemujju Bernard 0781396066

This document discusses Java keywords, operators, and assignment operators. It lists common Java keywords like abstract, assert, boolean, etc. that cannot be used as variable names. It describes arithmetic, relational, logical, bitwise, and assignment operators. Examples are provided to demonstrate how assignment operators like += work in Java programs.

Uploaded by

Edwins kato
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Java programming

lecture 2

By; Mr. Ssemujju Bernard


0781396066
bernardssemu@gmail.com
Universal Institute of Graphics and Technology
Java Keywords

 Java Keywords must be in your information because you can not use them as a
variable name.
Java Reserved Keywords List
 You can’t use keyword as identifier in your Java programs, its reserved words in Java
library and used to perform an internal operation.

 NOTE: true, false and null are not reserved words but cannot be used as identifiers,


because it is literals of built-in types.
Java Reserved Keywords List
Java Reserved Keywords List
abstract assert boolean break

byte case catch char


class const continue default
do double else enum
extends final finally float
for goto if implements
import instanceof int interface
long native new package
private protected public return
short static strictfp super
switch synchronized this throw
throws transient try void
volatile while  true  false
null
Java Operators

Java operators are symbols that are used to perform


mathematical or logical manipulations. Java is rich with built-
in operators.
Types of operators in Java:
 Arithmetic Operators
 Relational Operators
 Logical Operators
 Bitwise Operators
 Assignment Operators
 Misc Operators.
Arithmetic Operators

Operator Description

+ Addition

– Subtraction

* Multiplication

/ Division

% Modulus

++ Increment

−− Decrement
Relational Operators

Operator Description

== Is equal to

!= Is not equal to

>  Greater than

<  Less than

>= Greater than or equal to

<= Less than or equal to
Logical Operators

Operator Description

&& And operator. Performs a logical conjunction on two expressions.
(if both expressions evaluate to True, result is True. If either expression 
evaluates to False, result is False)

|| Or operator. Performs a logical disjunction on two expressions.
(if either or both expressions evaluate to True, result is True)

! Not operator. Performs logical negation on an expression.

Bitwise Operators

Operator Description
<<  Binary Left Shift Operator
>>  Binary Right Shift Operator
>>>  Shift right zero fill operator
~ Binary One’s Complement Operator
& Binary AND Operator
^ Binary XOR Operator
| Binary OR Operator
Assignment Operators

Operator Description

= Assign
+= Increments then assigns
-= Decrements then assigns
*= Multiplies, then assigns
/= Divides then assigns
%= Modulus then assigns
<<= Left shift and assigns
>>= Right shift and assigns
&= Bitwise AND assigns
^= Bitwise exclusive OR and assigns
|= Bitwise inclusive OR and assigns
Programs to Show How Assignment Operator Works

 Example:
 import java.util.*;
 import java.lang.*;
 import java.io.*;
  
 public class arithop {
 public static void main(String[] args) {
 int number1 = 6;
 int number2 = 8;
 int sum = number1 + number2;
 int dif = number1 - number2;
 int mul = number1 * number2;
 int quot = number1 / number2;
 int rem = number1 % number2;

 System.out.println("number1 is : " + number1);
 System.out.println("number2 is: " + number2);
 System.out.println("Sum is: " + sum);
 System.out.println("Difference is : " + dif);
 System.out.println("Multiplied value is : " + mul);
 System.out.println("Quotient is : " + quot);
 System.out.println("Remainder is : " + rem);
 }
 }

You might also like