SlideShare a Scribd company logo
Introduction
Java
JAVA
• Java is a programming language and a platform.
• Java is a high level, robust, object-oriented and secure programming
language.
• Java was developed by Sun Microsystems in the year 1995.
• James Gosling is known as the father of Java. Before Java, its name
was Oak. Later, James Gosling and his team changed the name from
Oak to Java.
Features of Java
• The primary objective of Java programming language was to make it portable, simple and secure
programming language.
• Simple
• Object-Oriented
• Portable: Java is portable because it facilitates you to carry the Java bytecode to any platform. It
doesn't require any implementation.
• Platform independent: Java code is compiled by the compiler and converted into bytecode. This
bytecode is a platform-independent code because it can be run on multiple platforms.
• Secured: Java is best known for its security. With Java, we can develop virus-free systems.
• Robust: : It uses strong memory management, exception handling and the type checking
mechanism is there in Java
• Interpreted:
• Multithreaded: A thread is like a separate program, executing concurrently. We can write Java
programs that deal with many tasks at once by defining multiple threads.
• Dynamic: Java is a dynamic language. It supports the dynamic loading of classes. It means classes
are loaded on demand.
Applications of Java
• 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.
Java Program compilation and Execution
• Java can be considered both a
compiled and an interpreted
language because its source code is
first compiled into a binary byte-code.
• This byte-code runs on the Java
Virtual Machine (JVM), which is
usually a software-based interpreter.
JVM
• JVM (Java Virtual Machine) is an abstract machine. It is called a
virtual machine. It is a specification that provides a runtime
environment in which Java bytecode can be executed.
• The JVM performs the following main tasks:
• Loads code : Classloader is a subsystem of JVM which is used to load
class files. Whenever we run the java program, it is loaded first by
the classloader.
• It Verifies code and Executes code
• Provides runtime environment
JRE
• JRE: Java Runtime Environment is a set of
software tools which are used for developing
Java applications.
• It is used to provide the runtime environment.
It is the implementation of JVM.
• It physically exists. It contains a set of libraries +
other files that JVM uses at runtime.
JDK
• The Java Development Kit (JDK) is a software
development environment that offers a
collection of tools and libraries necessary for
developing Java-based software applications.
• JDK contains:
• Java Runtime Environment (JRE),
• An interpreter/loader (Java),
• A compiler (javac),
• An archiver (jar).
Data Types
• Data types specify the different sizes and values that can be stored in
the variable.
• All variables must be declared before its use.
• 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.
Primitive Data Types
• There are 8 types of primitive data types:
• Boolean data type: The Boolean data type is used to store only two possible
values: true and false. This data type is used for simple flags that track
true/false conditions.
Boolean one = false ;
• byte data type: it is an 8-bit signed integer. Its value-range lies between -128
to 127. Its minimum value is -128 and maximum value is 127.
• Its default value is 0.
• byte a = 10;
• char data type: The char data type is a single 16-bit character.
• The char data type is used to store characters.
• Char BCA=‘a’;
Cont..
• short data type: The short data type is a 16-bit signed integer.
• Its value-range lies between -32,768 to 32,767 .
• Its minimum value is -32,768 and maximum value is 32,767.
• Its default value is 0.
• int data type: The int data type is a 32-bit integer. Its value-range lies between (-2^31) to
(2^31 -1) . Its minimum value is - 2,147,483,648 and maximum value is 2,147,483,647.
• Its default value is 0.
• int a = 144;
• long data type: The long data type is a 64-bit integer. Its value-range lies between (-
2^63) to (2^63 -1).
• Its default value is 0.
• long a = 45677L;
Cont..
• float data type: The float data type is a 32-bit floating point.
• Its default value is 0.0F.
• Range 3.4e-038 to 3.4e+038.
• float f1 = 234.5f
• double data type: The double data type is a double-precision 64-bit
floating point.
• The double data type is generally used for decimal values just like float.
• Its default value is 0.0d.
• double d1 = 12.3 ;
• Range 1.7e-308 to 1.7e+308.
Arrays
• Array is an object which contains elements of a similar data type.
• It is a data structure where we store similar elements. We can store
only a fixed set of elements in a Java array.
1. int a[]=new int[5]; //declaration and instantiation
a[0]=10; //initialization
a[1]=20;
2. int a[]={33,3,4,5}; //declaration, instantiation and initialization
Cont..
• The elements of an array are stored in a contiguous memory location.
• Array in Java is index-based.
• The first element of the array is stored at the 0th index, 2nd element
is stored on 1st index and so on.
Types of Array
• There are two types of array.
• Single Dimensional Array : stores data in a single row
• Multidimensional Array: data is stored in row and column based index.
• Syntax to Declare Multidimensional Array :
dataType [][]arrayRefVar;
dataType arrayRefVar[][];
Example: int[][] arr=new int[3][3];
arr[0][0]=1;
arr[0][1]=2;
arr[0][2]=3;
Exceptions in Java(arrays)
• Exceptions in Arrays: ArrayIndexOutOfBoundsException
• The Java Virtual Machine (JVM) throws this exception if we are trying
to access array elements beyond its size.
• ArrayStoreException is a runtime exception in Java that occurs when
we try to store the incorrect type of element into an array.
Cont..
• Advantages
• Code Optimization: It makes the code optimized, we can retrieve or sort the
data efficiently.
• Random access: We can get any data located at an index position.
• Disadvantages
• Size Limit: We can store only the fixed size of elements in the array. It doesn't
grow its size at runtime. To solve this problem, collection framework is used in
Java which grows automatically.
Final Variable
• When the final keyword is used with a variable of different data types
such as int, float, the value of the variable cannot be changed.
final int No_students = 100;
No_students = 130;
Comments In Java
• The Java comments are the statements in a program that are not
executed by the compiler and interpreter.
• Why Comments:
• Comments are used to make the program more readable by adding
the details of the code.
• It makes easy to maintain the code and to find the errors easily.
• The comments can be used to provide information or explanation
about the variable, method, class, or any statement.
• It can also be used in testing the alternative code.
Types of Comments
• Single Line Comment: Single-line comments start with two forward
slashes ( // ).
• //This is single line comment
• Multi Line Comment: The multi-line comment is used to comment
multiple lines of code.
• /* This is
multi line comment */
• Java Documentation Comment: Documentation comments are
usually used to write large programs for a project or software
application as it helps to create documentation API.
• Example: /** and */.
Access Modifiers
• The access modifiers in Java specifies the accessibility or scope of a
field, method, constructor, or class.
• We can change the access level of fields, constructors, methods, and
class by applying the access modifier on it.
• There are four types of Java access modifiers:
1. Public
2. Private
3. Protected
4. Default
Access Modifiers
• Private: The access level of a private modifier is only within the class.
It cannot be accessed from outside the class.
Example: private int data=40;
• Default: The access level of a default modifier is only within the
package. It cannot be accessed from outside the package.
• If you do not specify any access level, it will be the default.
• It is more restrictive than protected, and public.
Cont..
• Protected: The access level of a protected modifier is within the
package and outside the package through inheritance only.
• If there is no child class, it cannot be accessed from outside the
package.
• It provides more accessibility than the default modifier.
• Public: The access level of a public modifier is everywhere. It can be
accessed from within the class, outside the class, within the package
and outside the package.
Example: public class A{ ….}
Access Modifiers
Access Modifier within class within package outside package
by subclass only
outside package
Private Y N N N
Default Y Y N N
Protected Y Y Y N
Public Y Y Y Y
Class in Java
• Class is a template or blueprint from which objects are created.
• It is a logical entity.
• A class in Java can contain:
• Fields
• Methods
• Constructors
• Blocks
• Nested class and interface
Class
1. class <class_name>
{
fields;
methods;
}
2. class Rectangle{
int length;
int width;
void insert(int l,int w){
length=l;
width=w;
} }
Objects in Java
• An object is an instance of a class.
• A class is a template or blueprint from which objects are created. So,
an object is the instance(result) of a class.
• Object Definitions:
• An object is a real-world entity.
• An object is a runtime entity.
• The object is an entity which has state and behavior.
• The object is an instance of a class.
• An object has three characteristics:
• State: represents the data (value) of an object.
• Behavior: represents the behavior (functionality) of an object such as
deposit, withdraw, etc.
• Identity: An object identity is typically implemented via a unique ID.
The value of the ID is not visible to the external user. However, it is
used internally by the JVM to identify each object uniquely.
Create Object
1. Anonymous object:
new Rectangle();
2. Referential name object:
Rectangle r1=new Rectangle();

More Related Content

PPTX
Java Unit-1.1 chunri kyu shuru kar rh koi si je di of du th n high ch ka dh h...
PPTX
Java Jive 002.pptx
PPTX
Introduction to java Programming Language
PPTX
Core java
PPTX
Core java
PPTX
Introduction to Java Basics Programming Java Basics-I.pptx
PPT
Java introduction
DOCX
OOP-Chap2.docx
Java Unit-1.1 chunri kyu shuru kar rh koi si je di of du th n high ch ka dh h...
Java Jive 002.pptx
Introduction to java Programming Language
Core java
Core java
Introduction to Java Basics Programming Java Basics-I.pptx
Java introduction
OOP-Chap2.docx

Similar to intro_java (1).pptx (20)

PPTX
Java platform
PPTX
UNIT – 2 Features of java- (Shilpa R).pptx
PPTX
Advanced java programming - DATA TYPES, VARIABLES, ARRAYS
PDF
java notes.pdf
PPTX
Unit-1_GHD.pptxguguigihihihihihihoihihhi
PPTX
Android webinar class_java_review
PPT
Java SpringMVC SpringBOOT (Divergent).ppt
PPTX
Presentation2.ppt java basic core ppt .
PPSX
Java session3
PPTX
2. Introduction to Java for engineering stud
PPTX
Learning core java
PPTX
L2 datatypes and variables
PPTX
Java Basics.pptx from nit patna ece department
PPTX
COMPUTER PROGRAMMING LANGUAGE.pptx
PPTX
PPTX
JAVA(module1).pptx
DOC
java handout.doc
PPTX
Introduction to JcjfjfjfkuutyuyrsdterdfbvAVA.pptx
PPTX
ppt_on_java.pptx
PPTX
Chapter 2 java
Java platform
UNIT – 2 Features of java- (Shilpa R).pptx
Advanced java programming - DATA TYPES, VARIABLES, ARRAYS
java notes.pdf
Unit-1_GHD.pptxguguigihihihihihihoihihhi
Android webinar class_java_review
Java SpringMVC SpringBOOT (Divergent).ppt
Presentation2.ppt java basic core ppt .
Java session3
2. Introduction to Java for engineering stud
Learning core java
L2 datatypes and variables
Java Basics.pptx from nit patna ece department
COMPUTER PROGRAMMING LANGUAGE.pptx
JAVA(module1).pptx
java handout.doc
Introduction to JcjfjfjfkuutyuyrsdterdfbvAVA.pptx
ppt_on_java.pptx
Chapter 2 java
Ad

Recently uploaded (20)

PPTX
_ISO_Presentation_ISO 9001 and 45001.pptx
PDF
Organizational Effectiveness in companies
PDF
ANIn Mumbai 2025 | Measuring Business Value during Agile Transformation by Pr...
PPTX
The Sustainable Site: Boosting Productivity in Construction – Pipe Dream or P...
PPTX
WORLD TRADE ORAGANIZATION- INSTITUTION TO MANAGE TRADE BETWEEN NATIONS
PPTX
Self-Awareness and Values Development presentation
PPTX
International trading agreements in world.pptx
PDF
The Sustainable Site: Boosting Productivity in Construction – Pipe Dream or P...
PPT
Introduction to Operations And Supply Management
PPTX
Presentation on Housekeeping Issue @RP.pptx
PPTX
TCoE_IT_Concrete industry.why is it required
PDF
Maintaining a Quality Culture - Performance Metrics, Best Practices and QMS E...
PPTX
Management and Leadership across culture at McDonald's
PPTX
INTELLECTUAL PROPERTY LAW IN UGANDA.pptx
PPTX
Spotlight on road Injury in the Philippines
PDF
How to Present a Project Proposal to Stakeholders for Approval?
PPTX
Testing center of excellence how to, why required
PPTX
Ryan Daly Gallardo Prod Management PPT .pptx
PDF
Boost the power of design | Design Impulse
PPT
Operations Management Supply-Chain Management
_ISO_Presentation_ISO 9001 and 45001.pptx
Organizational Effectiveness in companies
ANIn Mumbai 2025 | Measuring Business Value during Agile Transformation by Pr...
The Sustainable Site: Boosting Productivity in Construction – Pipe Dream or P...
WORLD TRADE ORAGANIZATION- INSTITUTION TO MANAGE TRADE BETWEEN NATIONS
Self-Awareness and Values Development presentation
International trading agreements in world.pptx
The Sustainable Site: Boosting Productivity in Construction – Pipe Dream or P...
Introduction to Operations And Supply Management
Presentation on Housekeeping Issue @RP.pptx
TCoE_IT_Concrete industry.why is it required
Maintaining a Quality Culture - Performance Metrics, Best Practices and QMS E...
Management and Leadership across culture at McDonald's
INTELLECTUAL PROPERTY LAW IN UGANDA.pptx
Spotlight on road Injury in the Philippines
How to Present a Project Proposal to Stakeholders for Approval?
Testing center of excellence how to, why required
Ryan Daly Gallardo Prod Management PPT .pptx
Boost the power of design | Design Impulse
Operations Management Supply-Chain Management
Ad

intro_java (1).pptx

  • 2. JAVA • Java is a programming language and a platform. • Java is a high level, robust, object-oriented and secure programming language. • Java was developed by Sun Microsystems in the year 1995. • James Gosling is known as the father of Java. Before Java, its name was Oak. Later, James Gosling and his team changed the name from Oak to Java.
  • 3. Features of Java • The primary objective of Java programming language was to make it portable, simple and secure programming language. • Simple • Object-Oriented • Portable: Java is portable because it facilitates you to carry the Java bytecode to any platform. It doesn't require any implementation. • Platform independent: Java code is compiled by the compiler and converted into bytecode. This bytecode is a platform-independent code because it can be run on multiple platforms. • Secured: Java is best known for its security. With Java, we can develop virus-free systems. • Robust: : It uses strong memory management, exception handling and the type checking mechanism is there in Java • Interpreted: • Multithreaded: A thread is like a separate program, executing concurrently. We can write Java programs that deal with many tasks at once by defining multiple threads. • Dynamic: Java is a dynamic language. It supports the dynamic loading of classes. It means classes are loaded on demand.
  • 4. Applications of Java • 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.
  • 5. Java Program compilation and Execution • Java can be considered both a compiled and an interpreted language because its source code is first compiled into a binary byte-code. • This byte-code runs on the Java Virtual Machine (JVM), which is usually a software-based interpreter.
  • 6. JVM • JVM (Java Virtual Machine) is an abstract machine. It is called a virtual machine. It is a specification that provides a runtime environment in which Java bytecode can be executed. • The JVM performs the following main tasks: • Loads code : Classloader is a subsystem of JVM which is used to load class files. Whenever we run the java program, it is loaded first by the classloader. • It Verifies code and Executes code • Provides runtime environment
  • 7. JRE • JRE: Java Runtime Environment is a set of software tools which are used for developing Java applications. • It is used to provide the runtime environment. It is the implementation of JVM. • It physically exists. It contains a set of libraries + other files that JVM uses at runtime.
  • 8. JDK • The Java Development Kit (JDK) is a software development environment that offers a collection of tools and libraries necessary for developing Java-based software applications. • JDK contains: • Java Runtime Environment (JRE), • An interpreter/loader (Java), • A compiler (javac), • An archiver (jar).
  • 9. Data Types • Data types specify the different sizes and values that can be stored in the variable. • All variables must be declared before its use. • 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.
  • 10. Primitive Data Types • There are 8 types of primitive data types: • Boolean data type: The Boolean data type is used to store only two possible values: true and false. This data type is used for simple flags that track true/false conditions. Boolean one = false ; • byte data type: it is an 8-bit signed integer. Its value-range lies between -128 to 127. Its minimum value is -128 and maximum value is 127. • Its default value is 0. • byte a = 10; • char data type: The char data type is a single 16-bit character. • The char data type is used to store characters. • Char BCA=‘a’;
  • 11. Cont.. • short data type: The short data type is a 16-bit signed integer. • Its value-range lies between -32,768 to 32,767 . • Its minimum value is -32,768 and maximum value is 32,767. • Its default value is 0. • int data type: The int data type is a 32-bit integer. Its value-range lies between (-2^31) to (2^31 -1) . Its minimum value is - 2,147,483,648 and maximum value is 2,147,483,647. • Its default value is 0. • int a = 144; • long data type: The long data type is a 64-bit integer. Its value-range lies between (- 2^63) to (2^63 -1). • Its default value is 0. • long a = 45677L;
  • 12. Cont.. • float data type: The float data type is a 32-bit floating point. • Its default value is 0.0F. • Range 3.4e-038 to 3.4e+038. • float f1 = 234.5f • double data type: The double data type is a double-precision 64-bit floating point. • The double data type is generally used for decimal values just like float. • Its default value is 0.0d. • double d1 = 12.3 ; • Range 1.7e-308 to 1.7e+308.
  • 13. Arrays • Array is an object which contains elements of a similar data type. • It is a data structure where we store similar elements. We can store only a fixed set of elements in a Java array. 1. int a[]=new int[5]; //declaration and instantiation a[0]=10; //initialization a[1]=20; 2. int a[]={33,3,4,5}; //declaration, instantiation and initialization
  • 14. Cont.. • The elements of an array are stored in a contiguous memory location. • Array in Java is index-based. • The first element of the array is stored at the 0th index, 2nd element is stored on 1st index and so on.
  • 15. Types of Array • There are two types of array. • Single Dimensional Array : stores data in a single row • Multidimensional Array: data is stored in row and column based index. • Syntax to Declare Multidimensional Array : dataType [][]arrayRefVar; dataType arrayRefVar[][]; Example: int[][] arr=new int[3][3]; arr[0][0]=1; arr[0][1]=2; arr[0][2]=3;
  • 16. Exceptions in Java(arrays) • Exceptions in Arrays: ArrayIndexOutOfBoundsException • The Java Virtual Machine (JVM) throws this exception if we are trying to access array elements beyond its size. • ArrayStoreException is a runtime exception in Java that occurs when we try to store the incorrect type of element into an array.
  • 17. Cont.. • Advantages • Code Optimization: It makes the code optimized, we can retrieve or sort the data efficiently. • Random access: We can get any data located at an index position. • Disadvantages • Size Limit: We can store only the fixed size of elements in the array. It doesn't grow its size at runtime. To solve this problem, collection framework is used in Java which grows automatically.
  • 18. Final Variable • When the final keyword is used with a variable of different data types such as int, float, the value of the variable cannot be changed. final int No_students = 100; No_students = 130;
  • 19. Comments In Java • The Java comments are the statements in a program that are not executed by the compiler and interpreter. • Why Comments: • Comments are used to make the program more readable by adding the details of the code. • It makes easy to maintain the code and to find the errors easily. • The comments can be used to provide information or explanation about the variable, method, class, or any statement. • It can also be used in testing the alternative code.
  • 20. Types of Comments • Single Line Comment: Single-line comments start with two forward slashes ( // ). • //This is single line comment • Multi Line Comment: The multi-line comment is used to comment multiple lines of code. • /* This is multi line comment */ • Java Documentation Comment: Documentation comments are usually used to write large programs for a project or software application as it helps to create documentation API. • Example: /** and */.
  • 21. Access Modifiers • The access modifiers in Java specifies the accessibility or scope of a field, method, constructor, or class. • We can change the access level of fields, constructors, methods, and class by applying the access modifier on it. • There are four types of Java access modifiers: 1. Public 2. Private 3. Protected 4. Default
  • 22. Access Modifiers • Private: The access level of a private modifier is only within the class. It cannot be accessed from outside the class. Example: private int data=40; • Default: The access level of a default modifier is only within the package. It cannot be accessed from outside the package. • If you do not specify any access level, it will be the default. • It is more restrictive than protected, and public.
  • 23. Cont.. • Protected: The access level of a protected modifier is within the package and outside the package through inheritance only. • If there is no child class, it cannot be accessed from outside the package. • It provides more accessibility than the default modifier. • Public: The access level of a public modifier is everywhere. It can be accessed from within the class, outside the class, within the package and outside the package. Example: public class A{ ….}
  • 24. Access Modifiers Access Modifier within class within package outside package by subclass only outside package Private Y N N N Default Y Y N N Protected Y Y Y N Public Y Y Y Y
  • 25. Class in Java • Class is a template or blueprint from which objects are created. • It is a logical entity. • A class in Java can contain: • Fields • Methods • Constructors • Blocks • Nested class and interface
  • 26. Class 1. class <class_name> { fields; methods; } 2. class Rectangle{ int length; int width; void insert(int l,int w){ length=l; width=w; } }
  • 27. Objects in Java • An object is an instance of a class. • A class is a template or blueprint from which objects are created. So, an object is the instance(result) of a class. • Object Definitions: • An object is a real-world entity. • An object is a runtime entity. • The object is an entity which has state and behavior. • The object is an instance of a class.
  • 28. • An object has three characteristics: • State: represents the data (value) of an object. • Behavior: represents the behavior (functionality) of an object such as deposit, withdraw, etc. • Identity: An object identity is typically implemented via a unique ID. The value of the ID is not visible to the external user. However, it is used internally by the JVM to identify each object uniquely.
  • 29. Create Object 1. Anonymous object: new Rectangle(); 2. Referential name object: Rectangle r1=new Rectangle();