Oops PPT Unit 1
Oops PPT Unit 1
YEAR/SEM : II/III
FACULTY NAME : T.Abitha kujalambal
DEPARTMENT : CSE
UNIT I
Overview of OOP – Object oriented programming paradigms – Features of Object Oriented Programming – Java
Buzzwords – Overview of Java – Data Types, Variables and Arrays –Operators – Control Statements –
Programming Structures in Java – Defining classes in Java- Constructors- Methods -Access specifiers - Static
members- Java Doc comments.
Text Books:
1.Herbert Schildt, “Java: The Complete Reference”, 11 th Edition, McGraw Hill Education,
New Delhi, 2019.
Encapsulation :
Abstraction – hiding the complex implementation details
of a class .
Hiding of data is known as data abstraction.
Polymorphism: representing one form in multiple
forms is known as Polymorphism.
Java Buzzwords Or Java Features :
Simple
Object Oriented
Platform Independence
Architecture Neural
Portable
Robust(strong)
Secure
Dynamic
Multithreaded
Distributed
Interpreter
High Performance
Overview of java :
Java is platform independent because it is compiled to a bytecode that can be run on any device
that has a java virtual machine .This means that you can write a java program on one Platform
(such as Windows )and then run it on a different (such as macos or linux )without making any
changes to the code .
Java is a versatile and widely-used programming language that was originally developed by Sun
Microsystems (now owned by Oracle) in the mid-1990s.
Java Excepted
Compiler Byte code Jvm
program output
Java Tokens :
Keywords
Identifiers
Constants
Operators
Separators
1.Keywords :
Keywords are special words which are used to recognize Structure Of Program
Each keyword having specific Task.
Most of the keywords are present Import ,class , void ,Try, Catch ,do ,for ,while ,if ,short ,int ,char ,float
,double ,long, break ,Continue, Default, else ….etc.
2.Identifiers :
Identifiers are user defined names
Rules :
2.1 Must start with a letter (a-z or A-Z), currency character ($) or underscore (_).
2.2 Can be followed by letters, digits (0-9), currency characters, or underscores.
2.3 Cannot contain spaces or special characters like @, #, *, etc. (except $ and _).
Datatypes Variables ,and Arrays :
Datatypes
Primitive datatypes
Primitive data types : Integer ,Byte ,short ,int ,long ,float ,double ,char ,Boolean.
Non –primitive datatypes : class, string ,Array .
Integers :
Name Width Range
Byte 8 -128 to 127
Int 32 -2,147,483,648
to2,147,483,647
Long 64 -9,223,372,036,854,775,808
to9,223,372,036,854,775,807
Floating Point Types:
int a = 10;
int b = 5;
Boolean result; result = (a == b); // false
result = (a != b); // true
result = (a > b); // true
result = (a < b); // false
result = (a >= b); // true
result = (a <= b); // false
Logical Operators:
These operators are used to combine multiple boolean expressions:
•&& : Logical LAND
•|| : Logical OR
•! : Logical NOT
Example:
boolean a = true;
boolean b = false;
boolean result;
result = a && b; // false
result = a || b; // true
result = !a; // false
Control Statement In Java:
Structure Of Java Programming :
Import java.io.*-package details
Class class name - -class demo
Void main()-user defined method
{
Block of statements;
}
Static method :
You Can create a static method by using the keyword static .
Can be called without the help of an object .
With the help of object
Can be called with class name .
Example of static methods :
Static Variable :
The static fields have the same value in all Instances of the class these are the class is loaded for the first time.
Just like static methods you can access specific fields using the class (without instantiation)
Example:
Static Blocks :
These are a block of codes with a static keyword .
In a general these are used to Initialize the static members.
Jvm Executes static blocks before the main method at the time of class loading static .
Java Doc comments :
Basic Structure:
•Javadoc comments start with /** and end with */.
•Each line inside the comment starts with a *.
Tags:
@param-for parameters of a method
@return-for the return of a method
@throws or Exception-for exception that a method can throw
@see-for reference to related methods or classes
@since-to indicate when a method or was added.