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

OOP Unit-I Java Introduction -I

Uploaded by

suganyatklncecs
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

OOP Unit-I Java Introduction -I

Uploaded by

suganyatklncecs
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 22

CS8392-Object

Oriented Programming
UNIT - I

INTRODUCTION TO OOP AND JAVA


FUNDAMENTALS

Prepared by,
Mrs. T. SUGANYA,
M.E.,
JAVA
Topics
Structure

Fundamental Programming
Structures in JAVA
Structure of Java Program
Addition of two numbers
import java.io.*;
class sum
{
public static void main(String
args[])
{
Int a=2,b=3,c;
c=a+b;
System.out.println(“Sum is =“+c);
}
Fundamental Programming
Structures
1. Identifiers
◦ Used for class names, variable
names, method names, package &
interface names
◦ Sequence of upper & lower chars.
◦ Must not begin with number
◦ Case sensitive
Valid Identifiers
Reg_no, ReGNO, name,
Invalid Identifiers
100roll, _you, avg&stu;
Fundamental Programming
Structures
Fundamental Programming
Structures
3. Comments
Single Line (2 forward slashes)- //
Multi Line - /* */
Documentation - /** */
Fundamental Programming
Structures
4. Separators
NO MEANIN SY PURPOSE
G M
B
OL
1 Parenthe () Used to enclose an argument in the method
ses definition defining the expression in control
statements.
2 Braces {} Used to define a block of code for classes and
methods
3 Brackets [] Used to declare an array type. Also used when
dereferencing array values.
4 Semicolo ; Used to separate or terminate the statement.
n
5 Comma , Used to separate identifiers (or) Variable
declarations. Also used to chain statements
together inside a for a statement.
Separators : Example
class separator
{
public static void main(String args[])
{
int a=10,b=15,c;
for(i=1,j=1; i<=10;i++)
{

System.out.println("is:"+math.sqrt(i))
}
}
}
Fundamental Programming
Structures
5. Keywords
Reserved Identifiers
can not be used as Identifier
names
Fundamental Programming
Structures
6. Datatypes
Strongly typed Language
Check the type during compilation
Fundamental Programming
Structures
Fundamental Programming
Structures
6. Datatypes with size and range
Fundamental Programming
Structures
7. Variable
Name of Memory Location/Identifier
Holds a Value
Value can be changed during the
execution
Declaration
Datatype Variable name;
int a;
Static : Initialization
Datatype var name=value;
int a=10;
Fundamental Programming
Structures
7. Variable
Dynamic : Initialization

class var
{
public static void main(String args[])
{
int a=10,b=15;
int c=(a+b)*100
System.out.println(“C value is=“+c)

}
}
Fundamental Programming
Structures
8. Operators
Symbols – performs an operation
Operand – values on which the
operation is performed (var/constant)
Eg. a+b 2+n

Four Group of Operators


1. Arithmetic
2. Bitwise
3. Relational
4. Logical
Fundamental Programming
Structures
Bitwise Operators
Bitwise Operators

a 0000 a 0000
0101 0100 04
B 0000 a<<1 0000
0100 1000 08
a&b 0000 0100 a<<1 0001
04 0000 16

a|b 0000
0101 05 b 0000
1000 08
Relational Operators
Logical Operators

You might also like