0% found this document useful (0 votes)
16 views33 pages

Oops PPT Unit 1

The document outlines the syllabus for CS3391 - Object Oriented Programming Language, focusing on Java and its features such as classes, objects, encapsulation, and polymorphism. It covers Java's data types, variables, arrays, operators, control statements, and constructors, along with the structure of Java programs. Key concepts include Java's platform independence, static members, and JavaDoc comments for documentation.
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)
16 views33 pages

Oops PPT Unit 1

The document outlines the syllabus for CS3391 - Object Oriented Programming Language, focusing on Java and its features such as classes, objects, encapsulation, and polymorphism. It covers Java's data types, variables, arrays, operators, control statements, and constructors, along with the structure of Java programs. Key concepts include Java's platform independence, static members, and JavaDoc comments for documentation.
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/ 33

Course Name

CS3391 – Object Oriented Programming Language

YEAR/SEM : II/III
FACULTY NAME : T.Abitha kujalambal
DEPARTMENT : CSE
UNIT I

INTRODUCTION TO OOP AND JAVA

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.

2. Herbert Schildt, “Introducing JavaFX 8 Programming”, 1st Edition, McGraw Hill


Education, New Delhi, 2015.
INTRODUCTION TO JAVA :

JAVA-Advanced oops Language .


Object oriented programming language everything deals with object .
 Java is a Simple Programming Language .
 Java is a Class Based object Oriented Programming .
 Java is a widely-used, high-level programming language .

Concepts Of Object Oriented Programming :


Or
Features Of Object Oriented Programming :

Class Object Encapsulation Polymorphism


Class: A class is a blueprint or template for creating
objects.
Object: An object is an instance of a class.

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.

How its works :

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

Non Primitive datatype

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

Short 16 -32,768 to 32,767

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:

Name Width in bits Range


Float 32 1.4e-0.45 to 3.4e+038
Double 64 4.9e-324 to1.8e+308
Variables in Java :

 Variable is an identifier which holds data or another one variable is an


identifier whose value can be changed at the execution time of
program.
 Variable is an identifier which can be used to identify input data in a
program.
Arrays in Java :
Arrays are commonly used for storing data and manipulating data in programming languages.
arrays are used to store multiple values of the same type under a single variable name.
Types of Array in Java:
There are two types of array in Java.
•Single Dimensional Array
•Multidimensional Array
Example Of Array :

public class ArrayEx


{ excepted Output:
public static void main(String []args)
{ 10
int arr[] = {10,20,30}; 20
for (int i=0; i < arr.length; i++)
{ 30
System.out.println(arr[i]);
}}
}
Operators in java :
Java, operators are special symbols used to perform
operations on variables and values.
Types of operators:
 Arithmetic Operators
Bitwise Operators
Relational Operators
Logical operators
Arithmetic Operators:
These operators are used to perform basic arithmetic operations:
•+ : Addition
•- : Subtraction
•* : Multiplication
•/ : Division
•% : Modulus (remainder)
Example:
int a = 10;
int b = 5;
int sum = a + b; // 15
int difference = a - b; // 5
int product = a * b; // 50
int quotient = a / b; // 2
int remainder = a % b; // 0
Bitwise Operators :

These operators are used to perform bit-level operations:


•& : Bitwise AND
•| : Bitwise OR
•^ : Bitwise XOR
•~ : Bitwise NOT
•<< : Left shift
•>> : Right shift
•>>> : Unsigned right shift
Example of Bitwise operators :

int a = 5; // 0101 in binary


int b = 3; // 0011 in binary
int result; result = a & b; // 0001 (1)
result = a | b; // 0111 (7)
result = a ^ b; // 0110 (6)
result = ~a; // 1010 (in 2's complement, it is -6)
result = a << 1; // 1010 (10) result = a >> 1; // 0010 (2) r
esult = a >>> 1; //
Relational operators

These operators are used to compare two values:


•== : Equal to
•!= : Not equal to
•> : Greater than
•< : Less than
•>= : Greater than or equal to
•<= : Less than or equal to
Examples Of Relational Operators :

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;
}

Package –Package is a collection of class .


Class: class is a keyword ,user defined data type every program must be start with class .
Block of statements :represents set of executable statements .
Example of java hello world program:
Class message
{
Public Static void main(string[] args)
{
System.out .println(“hello world”);
}
}
Excepted Output:
Hello world
Compiling The Program: Classname.java-message.java
Constructors in java :
 Constructor is a special method used to initialize objects.
 Constructors have the same name as the class name constructor do not have the return type.

• Default constructor does not take


Default any arguments
• If no Constructor java automatically
constructor provides default constructor.

• Parameterized constructor takes


Parameterized arguments to initialize objects
attribute with specific values.
constructor
Static Members in java :
 Static Members are those which belongs to the class and you can access these members without
instantiating the class .
 The Static keyword can be used with methods fields ,classes (inner ,nested ,blocks ).

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.

You might also like