SlideShare a Scribd company logo
1 of 32
Download to read offline
Java Programming
Unit-1
Dr. K ADISESHA
Introduction
Java Platforms
Features of Java
Java program
Java Control Structure
2
Java Tutorial
Prof. K. Adisesha
Introduction
Prof. K. Adisesha
3
Introduction:
Java is a general-purpose programming language intended to let programmers write
once, run anywhere (WORA). This means that compiled Java code can run on all
platforms that support Java without the need to recompile.
➢ Java is popular high-level, class-based object oriented programming language
originally developed by Sun Microsystems and released in 1995.
❖ Java is Open Source which means its available free of cost.
❖ Java is simple and so easy to learn
❖ Java is much in demand and ensures high salary
❖ Java has a large vibrant community
❖ Java has powerful development tools
❖ Java is platform independent
Introduction
Prof. K. Adisesha
4
History of Java:
James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language
project in June 1991. The small team of sun engineers called Green Team.
➢ Initially it was designed for small, embedded systems in electronic appliances like set-top
boxes.
➢ Firstly, it was called "Greentalk" by James Gosling, and the file extension was .gt.
➢ After that, it was called Oak and was developed as a part of the Green project.
➢ In 1995, Oak was renamed as "Java" because it was already a trademark by Oak
Technologies.
➢ Initially developed by James Gosling at Sun Microsystems (which is now a subsidiary of
Oracle Corporation) and released in 1995.
Introduction
Prof. K. Adisesha
5
History of Java:
James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language
project in June 1991. The small team of sun engineers called Green Team.
➢ Many java versions have been released till now: JDK Alpha and Beta (1995), JDK 1.0( 1996) to
Java SE 18 (to be released by March 2022)
➢ Popular Java Editors :To write your Java programs, you will need a text editor. There
are even more sophisticated IDEs available in the market.
❖ Notepad − On Windows machine, you can use any simple text editor like Notepad
(Recommended for this tutorial).
❖ Netbeans − A Java IDE that is open-source and free which can be downloaded from
https://www.netbeans.org/index.html.
❖ Eclipse − A Java IDE developed by the eclipse open-source community and can be
downloaded from https://www.eclipse.org/.
Introduction
Prof. K. Adisesha
6
Application:
According to Sun, 3 billion devices run Java. There are many devices where Java is
currently used.
➢ Some of them are as follows:
❖ Desktop Applications such as acrobat reader, media player, antivirus, etc.
❖ Web Applications such as irctc.co.in, javatpoint.com, etc.
❖ Enterprise Applications such as banking applications.
❖ Mobile
❖ Embedded System
❖ Smart Card
❖ Robotics
❖ Games, etc.
Introduction
Prof. K. Adisesha
7
Java Platforms / Editions:
There are many types of applications that can be created using Java programming:
➢ There are 4 platforms or editions of Java:
➢ Java SE (Java Standard Edition):
➢ It is a Java programming platform. It includes Java programming APIs such as java.lang,
java.io, java.net, java.util, java.sql, java.math etc.
➢ Java EE (Java Enterprise Edition): It is an enterprise platform that is mainly used to develop
web and enterprise applications. It includes topics like Servlet, JSP, Web Services, EJB, JPA,
etc.
➢ Java ME (Java Micro Edition): It is a micro platform that is dedicated to mobile applications.
➢ JavaFX: It is used to develop rich internet applications. It uses a lightweight user interface
API.
Introduction
Prof. K. Adisesha
8
Features of Java:
The primary objective of Java programming language creation was to make it portable,
simple and secure programming language.
➢ Simple
➢ Object-Oriented
➢ Portable
➢ Platform independent
➢ Secured
➢ Robust
➢ Architecture neutral
➢ Interpreted
➢ Multithreaded
➢ Distributed
Introduction
Prof. K. Adisesha
9
Features of Java:
The primary objective of Java programming language creation was to make it portable,
simple and secure programming language.
➢ Object Oriented − In Java, everything is an Object. Java can be easily extended since it is based on
the Object model.
➢ Platform Independent − When Java is compiled, it is not compiled into platform specific machine,
rather into platform independent byte code.
➢ Simple − Java is designed to be easy to learn. If you understand the basic concept of OOP Java, it
would be easy to master.
➢ Secure − With Java's secure feature it enables to develop virus-free, tamper-free systems.
Authentication techniques are based on public-key encryption.
➢ Architecture-neutral − Java compiler generates an architecture-neutral object file format, which
makes the compiled code executable on many processors, with the presence of Java runtime system.
Introduction
Prof. K. Adisesha
10
Features of Java:
The primary objective of Java programming language creation was to make it portable,
simple and secure programming language.
➢ Portable − Being architecture-neutral and having no implementation dependent aspects of the
specification makes Java portable.
➢ Robust − Java makes an effort to eliminate error prone situations by emphasizing mainly on
compile time error checking and runtime checking.
➢ Multithreaded − With Java's multithreaded feature it is possible to write programs that can
perform many tasks simultaneously.
➢ High Performance − With the use of Just-In-Time compilers, Java enables high performance.
➢ Distributed − Java is designed for the distributed environment of the internet.
➢ Dynamic − Java programs can carry extensive amount of run-time information that can be used
to verify and resolve accesses to objects on run-time.
Introduction
Prof. K. Adisesha
11
OOPs Concepts in Java:
The basic concept of OOPs is to create objects, re-use them throughout the program, and
manipulate these objects to get results.
➢ Class − The class is one of the Basic concepts of OOPs which is a group of similar entities. It is
only a logical component and not the physical entity.
➢ Object - An object can be defined as an instance of a class, and there can be multiple instances of
a class in a program.
➢ Inheritance - Inheritance is one of the Basic Concepts of OOPs in which one object acquires the
properties and behaviors of the parent object.
➢ Polymorphism - Polymorphism refers to one of the OOPs concepts in Java which is the ability of
a variable, object or function to take on multiple forms.
➢ Abstraction - Abstraction is one of the OOP Concepts in Java which is an act of representing
essential features without including background details.
Introduction
Prof. K. Adisesha
12
OOPs Concepts in Java:
The basic concept of OOPs is to create objects, re-use them throughout the program, and
manipulate these objects to get results.
➢ Encapsulation − Encapsulation is one of the best Java OOPs concepts of wrapping the data and
code. In this OOPs concept, the variables of a class are always hidden from other classes.
➢ Association - Association is a relationship between two objects. It is one of the OOP Concepts in
Java which defines the diversity between objects. In this OOP concept, all objects have their
separate lifecycle, and there is no owner.
➢ Aggregation - In this technique, all objects have their separate lifecycle. However, there is
ownership such that child object can’t belong to another parent object.
➢ Composition - Composition is a specialized form of Aggregation. It is also called “death”
relationship. Child objects do not have their lifecycle so when parent object deletes all child
object will also delete automatically.
Introduction
Dr. K ADISESHA
13
C++ vs Java:
C++ Java
• C++ is platform-dependent. • Java is platform-independent.
• C++ is mainly used for system programming. • It is widely used in Windows-based, web-based,
enterprise, and mobile applications.
• C++ supports multiple inheritance. • It can be achieved by using interfaces in java.
• C++ supports goto statement, Pointers, operator
overloading.
• Java doesn't supports goto statement, Pointers,
operator overloading.
• C++ supports both call by value and call by
reference.
• Java supports call by value only. There is no call
by reference in java.
Introduction
Prof. K. Adisesha
14
Java Architecture:
Java Architecture combines the process of compilation and interpretation.
➢ In Java, there is a process of compilation and interpretation.
➢ The code written in Java, is converted into byte codes which is done by the Java Compiler.
➢ The byte codes, then are converted into machine code by the JVM.
➢ The Machine code is executed directly by the machine.
Java program
Prof. K. Adisesha
15
Java Program:
To create a simple Java program, you need to create a class that contains the main
method.
➢ For executing any Java program, the following software or application must be
properly installed.
➢ Install the JDK if you don't have installed it, download the JDK and install it.
➢ Set path of the jdk/bin directory.
➢ Create the Java program
➢ Compile and run the Java program
❖ To compile: javac Simple.java
❖ To execute: java Simple
class Simple{
public static void main(String args[])
{
System.out.println("Hello Java");
}
}
Java program
Prof. K. Adisesha
16
Basic Syntax:
Java program, can be defined as a collection of objects that communicate via invoking
each other's methods.
➢ It is very important to keep in mind the following points.
❖ Case Sensitivity − Java is case sensitive, which means identifier Hello and hello would have
different meaning in Java.
❖ Class Names − For all class names the first letter should be in Upper Case. If several words
are used to form a name of the class, each inner word's first letter should be in Upper Case.
Example: class MyFirstJavaClass
❖ Method Names − All method names should start with a Lower Case letter. If several words
are used to form the name of the method, then each inner word's first letter should be in
Upper Case. Example: public void myMethodName()
❖ Program File Name − Name of the program file should exactly match the class name.
Java program
Prof. K. Adisesha
17
Basic Syntax:
Java program, can be defined as a collection of objects that communicate via invoking
each other's methods.
Java program
Prof. K. Adisesha
18
Java I/O (Input and Output) :
Java uses the concept of a stream to make I/O operation fast. The java.io package
contains all the classes required for input and output operations.
➢ Java uses the concept of a stream to make I/O operation fast. The java.io package
contains all the classes required for input and output operations.
➢ A stream is a sequence of data. In Java, a stream is composed of bytes. It's called a
stream because it is like a stream of water that continues to flow.
➢ In Java, 3 streams are created for us automatically. All these streams are attached
with the console.
❖ System.out: standard output stream
❖ System.in: standard input stream
❖ System.err: standard error stream
Java program
Prof. K. Adisesha
19
Java Identifiers:
All Java components require names. Names used for classes, variables, and methods
are called identifiers.
➢ In Java, there are several points to remember about identifiers. They are as follows −
❖ All identifiers should begin with a letter (A to Z or a to z), currency character ($)
or an underscore (_).
❖ After the first character, identifiers can have any combination of characters.
❖ A key word cannot be used as an identifier.
❖ Most importantly, identifiers are case sensitive.
❖ Examples of legal identifiers: age, $salary, _value, __1_value.
❖ Examples of illegal identifiers: 123abc, -salary.
Java program
Prof. K. Adisesha
20
Java Variables:
A variable is a container which holds the value while the Java program is executed. A
variable is assigned with a data type.
➢ Variable is a name of memory location. There are three types of variables in java:
❖ local variable : A variable declared inside the body of the
method is called local variable.
❖ instance variable: A variable declared inside the class but
outside the body of the method, is called an instance variable.
❖ static variable : A variable that is declared as static is called
a static variable. It cannot be local. You can create a single
copy of the static variable and share it among all the
instances of the class.
public class A
{ static int m=100; //static variable
void method()
{
int n=90; //local variable
}
public static void main(String args[])
{
int data=50; //instance variable
}
} //end of class
Java program
Prof. K. Adisesha
21
Data Types in Java:
Data types specify the different sizes and values that can be stored in the variable.
➢ There are two types of data types in Java:
➢ Primitive data types: The primitive data
types include boolean, char, byte, short, int,
long, float and double.
➢ Non-primitive data types: The non-primitive
data types include Classes, Interfaces, and
Arrays.
Java program
Prof. K. Adisesha
22
Primitive data types: :
Data Type Characteristics Range
byte 8 bit signed integer -128 to 127
short 16 bit signed integer -32768 to 32767
int 32 bit signed integer -2,147,483,648 to 2,147,483,647
long 64 bit signed integer -9,223,372,036,854,775,808 to- 9,223,372,036,854,775,807
float 32 bit floating point number + 1.4E-45 to
+ 3.4028235E+38
double 64 bit floating point number + 4.9E-324 to
+ 1.7976931348623157E+308
boolean true or false NA, note Java booleans cannot be converted to or from other types
char 16 bit, Unicode Unicode character, u0000 to uFFFF Can mix with integer types
Operator Type Category Precedence
Unary postfix expr++ expr--
prefix ++expr --expr +expr -expr ~ !
Arithmetic multiplicative * / %
additive + -
Shift shift << >> >>>
Relational comparison < > <= >= instanceof
equality == !=
Bitwise bitwise AND &
bitwise exclusive OR ^
bitwise inclusive OR |
Logical logical AND &&
logical OR ||
Ternary ternary ? :
Assignment assignment = += -= *= /= %= &= ^= |= <<= >>= >>>=
Java program
Prof. K. Adisesha
23
Operators in Java:
Operator in Java is a symbol that is used to perform operations.
➢ Types of operators in Java:
❖ Unary Operator,
❖ Arithmetic Operator,
❖ Shift Operator,
❖ Relational Operator,
❖ Bitwise Operator,
❖ Logical Operator,
❖ Ternary Operator and
❖ Assignment Operator.
Java program
Prof. K. Adisesha
24
Java Keywords:
Java keywords are also known as reserved words. These are predefined words by Java
so they cannot be used as a variable or object name or class name.
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
Java program
Prof. K. Adisesha
25
Java Control Statements:
Java provides three types of control flow statements:
➢ Decision Making statements
❖ if statements
❖ switch statement
➢ Loop statements
❖ do while loop
❖ while loop
❖ for loop
❖ for-each loop
➢ Jump statements
❖ break statement
❖ continue statement
if(condition) {
statement 1; //executes when condition is true
}
else{
statement 2; //executes when condition is false
}
for(initialization; condition; increment/decrement){
//statement or code to be executed
}
Java program
Prof. K. Adisesha
26
Decision Making statements:
Decision-making statements decide which statement to execute and when. Decision-
making statements evaluate the Boolean expression and control the program flow
depending upon the result of the condition provided:
➢ If Statement:
❖ Simple if statement
❖ if-else statement
❖ if-else-if ladder
❖ Nested if-statement
public class Student
{
public static void main(String[] args)
{
int x = 10;
int y = 12;
if(x+y < 10) { System.out.println("x + y is less than 10"); }
else { System.out.println("x + y is greater than 20"); }
}
}
Java program
Prof. K. Adisesha
27
Decision Making statements:
Decision-making statements decide which statement to execute and when. Decision-
making statements evaluate the Boolean expression and control the program flow
depending upon the result of the condition provided: switch(expression) {
case value :
// Statements
break; // optional
case value :
// Statements
break; // optional
// You can have any number of case statements.
default : // Optional
// Statements
}
➢Switch Statement: In Java, Switch statements are
similar to if-else-if statements. The switch
statement contains multiple blocks of code called
cases and a single case is executed based on the
variable which is being switched
Java program
Prof. K. Adisesha
28
Loop Statements:
loop statements are used to execute the set of instructions in a repeated order. The
execution of the set of instructions depends upon a particular condition.
➢for loop : In Java, for loop is similar to C and C++. It enables us to initialize the loop variable,
check the condition, and increment/decrement in a single line of code.
for(initialization, condition, increment/decrement)
{ //block of statements }
➢while loop : It is also known as the entry-controlled loop since the condition is checked at the
start of the loop. If the condition is true, then the loop body will be executed.
➢do-while loop : It is also known as the exit-controlled loop since the condition is not checked in
advance. The syntax of the do-while loop is given below.
while(condition){
//looping statements
}
do {
//statements
} while (condition);
Java program
Prof. K. Adisesha
29
Java - Arrays:
Java provides a data structure, the array, which is used to store a collection of
sequential collection of elements of the same type.
➢ Declaring Array Variables:
dataType[] arrayRefVar; // preferred way.
or
dataType arrayRefVar[]; // works but not preferred way.
➢ Creating Arrays
arrayRefVar = new dataType[arraySize];
dataType[] arrayRefVar = new dataType[arraySize];
dataType[] arrayRefVar = {value0, value1, ..., valuek};
dataType[][] arrayRefVar = new dataType[Size][Size];
➢ Example:
double[] myList; // preferred way.
or
double myList[]; // works but not preferred way.
➢ Example:
double[] myList = new double[10];
or
double[] myList = {1.9, 2.9, 3.4, 3.5};
or
int[][] myNumbers = { {1, 2, 3, 4}, {5, 6, 7} };
Java program
Prof. K. Adisesha
30
Java Arrays Loop:
When processing array elements, we often use either for loop or foreach loop because
all of the elements in an array are of the same type and the size of the array is known.
➢ Passing Arrays to Methods: Just as you can pass primitive
type values to methods, you can also pass arrays to methods.
For example.
public static void printArray(int[] array) {
for (int i = 0; i < array.length; i++) {
System.out.print(array[i] + " ");
}
}.
public class TestArray
{
public static void main(String[] args)
{ double[] myList = {1.9, 2.9, 3.4, 3.5};
// Print all the array elements
for (double element: myList) {
System.out.println(element);
}
}
}
Java program
Prof. K. Adisesha
31
Program to Reverse a Number in Java:
public class ReverseNumber
{
public static void main(String[] args)
{
int number = 987654, reverse = 0;
while(number != 0)
{
int remainder = number % 10;
reverse = reverse * 10 + remainder;
number = number/10;
}
System.out.println("The reverse of the given number is: " + reverse);
}
}
Discussion
Prof. K. Adisesha (Ph. D)
32
Queries ?
Prof. K. Adisesha
9449081542

More Related Content

What's hot (20)

Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
Java
JavaJava
Java
 
Features of java
Features of javaFeatures of java
Features of java
 
Core java
Core java Core java
Core java
 
Training on Core java | PPT Presentation | Shravan Sanidhya
Training on Core java | PPT Presentation | Shravan SanidhyaTraining on Core java | PPT Presentation | Shravan Sanidhya
Training on Core java | PPT Presentation | Shravan Sanidhya
 
Basics of JAVA programming
Basics of JAVA programmingBasics of JAVA programming
Basics of JAVA programming
 
Introduction of java
Introduction  of javaIntroduction  of java
Introduction of java
 
Core Java
Core JavaCore Java
Core Java
 
Java platform
Java platformJava platform
Java platform
 
core java
core javacore java
core java
 
Java &amp; advanced java
Java &amp; advanced javaJava &amp; advanced java
Java &amp; advanced java
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
Java Programming for Designers
Java Programming for DesignersJava Programming for Designers
Java Programming for Designers
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
 
Java seminar
Java seminarJava seminar
Java seminar
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
 
Javascript
JavascriptJavascript
Javascript
 
Java Data Types
Java Data TypesJava Data Types
Java Data Types
 

Similar to JAVA PPT Part-1 BY ADI.pdf

Similar to JAVA PPT Part-1 BY ADI.pdf (20)

Java Tutorial to Learn Java Programming
Java Tutorial to Learn Java ProgrammingJava Tutorial to Learn Java Programming
Java Tutorial to Learn Java Programming
 
Programming in java ppt
Programming in java  pptProgramming in java  ppt
Programming in java ppt
 
Programming in java ppt
Programming in java  pptProgramming in java  ppt
Programming in java ppt
 
Java 2 computer science.pptx
Java 2 computer science.pptxJava 2 computer science.pptx
Java 2 computer science.pptx
 
Chapter 1 java
Chapter 1 java Chapter 1 java
Chapter 1 java
 
Java and its features
Java and its featuresJava and its features
Java and its features
 
Introduction to Java Programming.pdf
Introduction to Java Programming.pdfIntroduction to Java Programming.pdf
Introduction to Java Programming.pdf
 
TechSearchWeb Tutorials.pdf
TechSearchWeb Tutorials.pdfTechSearchWeb Tutorials.pdf
TechSearchWeb Tutorials.pdf
 
0f0cef_1dac552af56c4338ab0672859199e693.pdf
0f0cef_1dac552af56c4338ab0672859199e693.pdf0f0cef_1dac552af56c4338ab0672859199e693.pdf
0f0cef_1dac552af56c4338ab0672859199e693.pdf
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
TechSearchWeb.pdf
TechSearchWeb.pdfTechSearchWeb.pdf
TechSearchWeb.pdf
 
Technology Tutorial.pdf
Technology Tutorial.pdfTechnology Tutorial.pdf
Technology Tutorial.pdf
 
Java Basic.pdf
Java Basic.pdfJava Basic.pdf
Java Basic.pdf
 
JAVA PROGRAMMING-Unit I - Final PPT.pptx
JAVA PROGRAMMING-Unit I - Final PPT.pptxJAVA PROGRAMMING-Unit I - Final PPT.pptx
JAVA PROGRAMMING-Unit I - Final PPT.pptx
 
unit1.pptx
unit1.pptxunit1.pptx
unit1.pptx
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
JAVA INTRODUCTION - 1
JAVA INTRODUCTION - 1JAVA INTRODUCTION - 1
JAVA INTRODUCTION - 1
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Java (1)
Java (1)Java (1)
Java (1)
 

More from Prof. Dr. K. Adisesha

Software Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfSoftware Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfSoftware Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfSoftware Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfSoftware Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfSoftware Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfSoftware Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfProf. Dr. K. Adisesha
 
Computer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaComputer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaProf. Dr. K. Adisesha
 
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaCCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaProf. Dr. K. Adisesha
 
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaCCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaProf. Dr. K. Adisesha
 
CCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaCCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaProf. Dr. K. Adisesha
 
CCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfCCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfProf. Dr. K. Adisesha
 

More from Prof. Dr. K. Adisesha (20)

Software Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfSoftware Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdf
 
Software Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfSoftware Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdf
 
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfSoftware Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
 
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfSoftware Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
 
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfSoftware Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
 
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfSoftware Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
 
Computer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaComputer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. Adisesha
 
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaCCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
 
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaCCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
 
CCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaCCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. Adisesha
 
CCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfCCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdf
 
Introduction to Computers.pdf
Introduction to Computers.pdfIntroduction to Computers.pdf
Introduction to Computers.pdf
 
R_Programming.pdf
R_Programming.pdfR_Programming.pdf
R_Programming.pdf
 
Scholarship.pdf
Scholarship.pdfScholarship.pdf
Scholarship.pdf
 
Operating System-2 by Adi.pdf
Operating System-2 by Adi.pdfOperating System-2 by Adi.pdf
Operating System-2 by Adi.pdf
 
Operating System-1 by Adi.pdf
Operating System-1 by Adi.pdfOperating System-1 by Adi.pdf
Operating System-1 by Adi.pdf
 
Operating System-adi.pdf
Operating System-adi.pdfOperating System-adi.pdf
Operating System-adi.pdf
 
Data_structure using C-Adi.pdf
Data_structure using C-Adi.pdfData_structure using C-Adi.pdf
Data_structure using C-Adi.pdf
 
JAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdfJAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdf
 
JAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdfJAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdf
 

Recently uploaded

Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 

Recently uploaded (20)

Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 

JAVA PPT Part-1 BY ADI.pdf

  • 2. Introduction Java Platforms Features of Java Java program Java Control Structure 2 Java Tutorial Prof. K. Adisesha
  • 3. Introduction Prof. K. Adisesha 3 Introduction: Java is a general-purpose programming language intended to let programmers write once, run anywhere (WORA). This means that compiled Java code can run on all platforms that support Java without the need to recompile. ➢ Java is popular high-level, class-based object oriented programming language originally developed by Sun Microsystems and released in 1995. ❖ Java is Open Source which means its available free of cost. ❖ Java is simple and so easy to learn ❖ Java is much in demand and ensures high salary ❖ Java has a large vibrant community ❖ Java has powerful development tools ❖ Java is platform independent
  • 4. Introduction Prof. K. Adisesha 4 History of Java: James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June 1991. The small team of sun engineers called Green Team. ➢ Initially it was designed for small, embedded systems in electronic appliances like set-top boxes. ➢ Firstly, it was called "Greentalk" by James Gosling, and the file extension was .gt. ➢ After that, it was called Oak and was developed as a part of the Green project. ➢ In 1995, Oak was renamed as "Java" because it was already a trademark by Oak Technologies. ➢ Initially developed by James Gosling at Sun Microsystems (which is now a subsidiary of Oracle Corporation) and released in 1995.
  • 5. Introduction Prof. K. Adisesha 5 History of Java: James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June 1991. The small team of sun engineers called Green Team. ➢ Many java versions have been released till now: JDK Alpha and Beta (1995), JDK 1.0( 1996) to Java SE 18 (to be released by March 2022) ➢ Popular Java Editors :To write your Java programs, you will need a text editor. There are even more sophisticated IDEs available in the market. ❖ Notepad − On Windows machine, you can use any simple text editor like Notepad (Recommended for this tutorial). ❖ Netbeans − A Java IDE that is open-source and free which can be downloaded from https://www.netbeans.org/index.html. ❖ Eclipse − A Java IDE developed by the eclipse open-source community and can be downloaded from https://www.eclipse.org/.
  • 6. Introduction Prof. K. Adisesha 6 Application: According to Sun, 3 billion devices run Java. There are many devices where Java is currently used. ➢ Some of them are as follows: ❖ Desktop Applications such as acrobat reader, media player, antivirus, etc. ❖ Web Applications such as irctc.co.in, javatpoint.com, etc. ❖ Enterprise Applications such as banking applications. ❖ Mobile ❖ Embedded System ❖ Smart Card ❖ Robotics ❖ Games, etc.
  • 7. Introduction Prof. K. Adisesha 7 Java Platforms / Editions: There are many types of applications that can be created using Java programming: ➢ There are 4 platforms or editions of Java: ➢ Java SE (Java Standard Edition): ➢ It is a Java programming platform. It includes Java programming APIs such as java.lang, java.io, java.net, java.util, java.sql, java.math etc. ➢ Java EE (Java Enterprise Edition): It is an enterprise platform that is mainly used to develop web and enterprise applications. It includes topics like Servlet, JSP, Web Services, EJB, JPA, etc. ➢ Java ME (Java Micro Edition): It is a micro platform that is dedicated to mobile applications. ➢ JavaFX: It is used to develop rich internet applications. It uses a lightweight user interface API.
  • 8. Introduction Prof. K. Adisesha 8 Features of Java: The primary objective of Java programming language creation was to make it portable, simple and secure programming language. ➢ Simple ➢ Object-Oriented ➢ Portable ➢ Platform independent ➢ Secured ➢ Robust ➢ Architecture neutral ➢ Interpreted ➢ Multithreaded ➢ Distributed
  • 9. Introduction Prof. K. Adisesha 9 Features of Java: The primary objective of Java programming language creation was to make it portable, simple and secure programming language. ➢ Object Oriented − In Java, everything is an Object. Java can be easily extended since it is based on the Object model. ➢ Platform Independent − When Java is compiled, it is not compiled into platform specific machine, rather into platform independent byte code. ➢ Simple − Java is designed to be easy to learn. If you understand the basic concept of OOP Java, it would be easy to master. ➢ Secure − With Java's secure feature it enables to develop virus-free, tamper-free systems. Authentication techniques are based on public-key encryption. ➢ Architecture-neutral − Java compiler generates an architecture-neutral object file format, which makes the compiled code executable on many processors, with the presence of Java runtime system.
  • 10. Introduction Prof. K. Adisesha 10 Features of Java: The primary objective of Java programming language creation was to make it portable, simple and secure programming language. ➢ Portable − Being architecture-neutral and having no implementation dependent aspects of the specification makes Java portable. ➢ Robust − Java makes an effort to eliminate error prone situations by emphasizing mainly on compile time error checking and runtime checking. ➢ Multithreaded − With Java's multithreaded feature it is possible to write programs that can perform many tasks simultaneously. ➢ High Performance − With the use of Just-In-Time compilers, Java enables high performance. ➢ Distributed − Java is designed for the distributed environment of the internet. ➢ Dynamic − Java programs can carry extensive amount of run-time information that can be used to verify and resolve accesses to objects on run-time.
  • 11. Introduction Prof. K. Adisesha 11 OOPs Concepts in Java: The basic concept of OOPs is to create objects, re-use them throughout the program, and manipulate these objects to get results. ➢ Class − The class is one of the Basic concepts of OOPs which is a group of similar entities. It is only a logical component and not the physical entity. ➢ Object - An object can be defined as an instance of a class, and there can be multiple instances of a class in a program. ➢ Inheritance - Inheritance is one of the Basic Concepts of OOPs in which one object acquires the properties and behaviors of the parent object. ➢ Polymorphism - Polymorphism refers to one of the OOPs concepts in Java which is the ability of a variable, object or function to take on multiple forms. ➢ Abstraction - Abstraction is one of the OOP Concepts in Java which is an act of representing essential features without including background details.
  • 12. Introduction Prof. K. Adisesha 12 OOPs Concepts in Java: The basic concept of OOPs is to create objects, re-use them throughout the program, and manipulate these objects to get results. ➢ Encapsulation − Encapsulation is one of the best Java OOPs concepts of wrapping the data and code. In this OOPs concept, the variables of a class are always hidden from other classes. ➢ Association - Association is a relationship between two objects. It is one of the OOP Concepts in Java which defines the diversity between objects. In this OOP concept, all objects have their separate lifecycle, and there is no owner. ➢ Aggregation - In this technique, all objects have their separate lifecycle. However, there is ownership such that child object can’t belong to another parent object. ➢ Composition - Composition is a specialized form of Aggregation. It is also called “death” relationship. Child objects do not have their lifecycle so when parent object deletes all child object will also delete automatically.
  • 13. Introduction Dr. K ADISESHA 13 C++ vs Java: C++ Java • C++ is platform-dependent. • Java is platform-independent. • C++ is mainly used for system programming. • It is widely used in Windows-based, web-based, enterprise, and mobile applications. • C++ supports multiple inheritance. • It can be achieved by using interfaces in java. • C++ supports goto statement, Pointers, operator overloading. • Java doesn't supports goto statement, Pointers, operator overloading. • C++ supports both call by value and call by reference. • Java supports call by value only. There is no call by reference in java.
  • 14. Introduction Prof. K. Adisesha 14 Java Architecture: Java Architecture combines the process of compilation and interpretation. ➢ In Java, there is a process of compilation and interpretation. ➢ The code written in Java, is converted into byte codes which is done by the Java Compiler. ➢ The byte codes, then are converted into machine code by the JVM. ➢ The Machine code is executed directly by the machine.
  • 15. Java program Prof. K. Adisesha 15 Java Program: To create a simple Java program, you need to create a class that contains the main method. ➢ For executing any Java program, the following software or application must be properly installed. ➢ Install the JDK if you don't have installed it, download the JDK and install it. ➢ Set path of the jdk/bin directory. ➢ Create the Java program ➢ Compile and run the Java program ❖ To compile: javac Simple.java ❖ To execute: java Simple class Simple{ public static void main(String args[]) { System.out.println("Hello Java"); } }
  • 16. Java program Prof. K. Adisesha 16 Basic Syntax: Java program, can be defined as a collection of objects that communicate via invoking each other's methods. ➢ It is very important to keep in mind the following points. ❖ Case Sensitivity − Java is case sensitive, which means identifier Hello and hello would have different meaning in Java. ❖ Class Names − For all class names the first letter should be in Upper Case. If several words are used to form a name of the class, each inner word's first letter should be in Upper Case. Example: class MyFirstJavaClass ❖ Method Names − All method names should start with a Lower Case letter. If several words are used to form the name of the method, then each inner word's first letter should be in Upper Case. Example: public void myMethodName() ❖ Program File Name − Name of the program file should exactly match the class name.
  • 17. Java program Prof. K. Adisesha 17 Basic Syntax: Java program, can be defined as a collection of objects that communicate via invoking each other's methods.
  • 18. Java program Prof. K. Adisesha 18 Java I/O (Input and Output) : Java uses the concept of a stream to make I/O operation fast. The java.io package contains all the classes required for input and output operations. ➢ Java uses the concept of a stream to make I/O operation fast. The java.io package contains all the classes required for input and output operations. ➢ A stream is a sequence of data. In Java, a stream is composed of bytes. It's called a stream because it is like a stream of water that continues to flow. ➢ In Java, 3 streams are created for us automatically. All these streams are attached with the console. ❖ System.out: standard output stream ❖ System.in: standard input stream ❖ System.err: standard error stream
  • 19. Java program Prof. K. Adisesha 19 Java Identifiers: All Java components require names. Names used for classes, variables, and methods are called identifiers. ➢ In Java, there are several points to remember about identifiers. They are as follows − ❖ All identifiers should begin with a letter (A to Z or a to z), currency character ($) or an underscore (_). ❖ After the first character, identifiers can have any combination of characters. ❖ A key word cannot be used as an identifier. ❖ Most importantly, identifiers are case sensitive. ❖ Examples of legal identifiers: age, $salary, _value, __1_value. ❖ Examples of illegal identifiers: 123abc, -salary.
  • 20. Java program Prof. K. Adisesha 20 Java Variables: A variable is a container which holds the value while the Java program is executed. A variable is assigned with a data type. ➢ Variable is a name of memory location. There are three types of variables in java: ❖ local variable : A variable declared inside the body of the method is called local variable. ❖ instance variable: A variable declared inside the class but outside the body of the method, is called an instance variable. ❖ static variable : A variable that is declared as static is called a static variable. It cannot be local. You can create a single copy of the static variable and share it among all the instances of the class. public class A { static int m=100; //static variable void method() { int n=90; //local variable } public static void main(String args[]) { int data=50; //instance variable } } //end of class
  • 21. Java program Prof. K. Adisesha 21 Data Types in Java: Data types specify the different sizes and values that can be stored in the variable. ➢ There are two types of data types in Java: ➢ Primitive data types: The primitive data types include boolean, char, byte, short, int, long, float and double. ➢ Non-primitive data types: The non-primitive data types include Classes, Interfaces, and Arrays.
  • 22. Java program Prof. K. Adisesha 22 Primitive data types: : Data Type Characteristics Range byte 8 bit signed integer -128 to 127 short 16 bit signed integer -32768 to 32767 int 32 bit signed integer -2,147,483,648 to 2,147,483,647 long 64 bit signed integer -9,223,372,036,854,775,808 to- 9,223,372,036,854,775,807 float 32 bit floating point number + 1.4E-45 to + 3.4028235E+38 double 64 bit floating point number + 4.9E-324 to + 1.7976931348623157E+308 boolean true or false NA, note Java booleans cannot be converted to or from other types char 16 bit, Unicode Unicode character, u0000 to uFFFF Can mix with integer types
  • 23. Operator Type Category Precedence Unary postfix expr++ expr-- prefix ++expr --expr +expr -expr ~ ! Arithmetic multiplicative * / % additive + - Shift shift << >> >>> Relational comparison < > <= >= instanceof equality == != Bitwise bitwise AND & bitwise exclusive OR ^ bitwise inclusive OR | Logical logical AND && logical OR || Ternary ternary ? : Assignment assignment = += -= *= /= %= &= ^= |= <<= >>= >>>= Java program Prof. K. Adisesha 23 Operators in Java: Operator in Java is a symbol that is used to perform operations. ➢ Types of operators in Java: ❖ Unary Operator, ❖ Arithmetic Operator, ❖ Shift Operator, ❖ Relational Operator, ❖ Bitwise Operator, ❖ Logical Operator, ❖ Ternary Operator and ❖ Assignment Operator.
  • 24. Java program Prof. K. Adisesha 24 Java Keywords: Java keywords are also known as reserved words. These are predefined words by Java so they cannot be used as a variable or object name or class name. 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
  • 25. Java program Prof. K. Adisesha 25 Java Control Statements: Java provides three types of control flow statements: ➢ Decision Making statements ❖ if statements ❖ switch statement ➢ Loop statements ❖ do while loop ❖ while loop ❖ for loop ❖ for-each loop ➢ Jump statements ❖ break statement ❖ continue statement if(condition) { statement 1; //executes when condition is true } else{ statement 2; //executes when condition is false } for(initialization; condition; increment/decrement){ //statement or code to be executed }
  • 26. Java program Prof. K. Adisesha 26 Decision Making statements: Decision-making statements decide which statement to execute and when. Decision- making statements evaluate the Boolean expression and control the program flow depending upon the result of the condition provided: ➢ If Statement: ❖ Simple if statement ❖ if-else statement ❖ if-else-if ladder ❖ Nested if-statement public class Student { public static void main(String[] args) { int x = 10; int y = 12; if(x+y < 10) { System.out.println("x + y is less than 10"); } else { System.out.println("x + y is greater than 20"); } } }
  • 27. Java program Prof. K. Adisesha 27 Decision Making statements: Decision-making statements decide which statement to execute and when. Decision- making statements evaluate the Boolean expression and control the program flow depending upon the result of the condition provided: switch(expression) { case value : // Statements break; // optional case value : // Statements break; // optional // You can have any number of case statements. default : // Optional // Statements } ➢Switch Statement: In Java, Switch statements are similar to if-else-if statements. The switch statement contains multiple blocks of code called cases and a single case is executed based on the variable which is being switched
  • 28. Java program Prof. K. Adisesha 28 Loop Statements: loop statements are used to execute the set of instructions in a repeated order. The execution of the set of instructions depends upon a particular condition. ➢for loop : In Java, for loop is similar to C and C++. It enables us to initialize the loop variable, check the condition, and increment/decrement in a single line of code. for(initialization, condition, increment/decrement) { //block of statements } ➢while loop : It is also known as the entry-controlled loop since the condition is checked at the start of the loop. If the condition is true, then the loop body will be executed. ➢do-while loop : It is also known as the exit-controlled loop since the condition is not checked in advance. The syntax of the do-while loop is given below. while(condition){ //looping statements } do { //statements } while (condition);
  • 29. Java program Prof. K. Adisesha 29 Java - Arrays: Java provides a data structure, the array, which is used to store a collection of sequential collection of elements of the same type. ➢ Declaring Array Variables: dataType[] arrayRefVar; // preferred way. or dataType arrayRefVar[]; // works but not preferred way. ➢ Creating Arrays arrayRefVar = new dataType[arraySize]; dataType[] arrayRefVar = new dataType[arraySize]; dataType[] arrayRefVar = {value0, value1, ..., valuek}; dataType[][] arrayRefVar = new dataType[Size][Size]; ➢ Example: double[] myList; // preferred way. or double myList[]; // works but not preferred way. ➢ Example: double[] myList = new double[10]; or double[] myList = {1.9, 2.9, 3.4, 3.5}; or int[][] myNumbers = { {1, 2, 3, 4}, {5, 6, 7} };
  • 30. Java program Prof. K. Adisesha 30 Java Arrays Loop: When processing array elements, we often use either for loop or foreach loop because all of the elements in an array are of the same type and the size of the array is known. ➢ Passing Arrays to Methods: Just as you can pass primitive type values to methods, you can also pass arrays to methods. For example. public static void printArray(int[] array) { for (int i = 0; i < array.length; i++) { System.out.print(array[i] + " "); } }. public class TestArray { public static void main(String[] args) { double[] myList = {1.9, 2.9, 3.4, 3.5}; // Print all the array elements for (double element: myList) { System.out.println(element); } } }
  • 31. Java program Prof. K. Adisesha 31 Program to Reverse a Number in Java: public class ReverseNumber { public static void main(String[] args) { int number = 987654, reverse = 0; while(number != 0) { int remainder = number % 10; reverse = reverse * 10 + remainder; number = number/10; } System.out.println("The reverse of the given number is: " + reverse); } }
  • 32. Discussion Prof. K. Adisesha (Ph. D) 32 Queries ? Prof. K. Adisesha 9449081542