CHHATRAPATI SHAHU JI MAHARAJ UNIVERSITY KANPUR
PRESENTATION ON INTRODUCTION TO JAVA PROGRAMMING
Presented by -:
 Nitish Chaulagai
In the guidance of
respected sir
 Mr. Shivneet Tripathi
Introduction
 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 (which is now the subsidiary of
Oracle) in the year 1995. James Gosling is known as the father of Java.
Types of Java Application
 Standalone Application
 Web Application
 Enterprise Application
 Mobile Application
Features of Java
 Object Oriented
 Platform Independent
 Portable
 Interpreted
 Robust
 Multithreaded etc.
OOPs (Object Oriented Programming
system)
 OBJECT
 CLASS
 INHERITENCE
 POLYMORPHISM
 ABSTRACTION
 ENCAPSULATION
Object-Oriented Programming is a methodology or paradigm to design a
program using classes and objects . It simplifies software development and
maintenance by providing some concepts-:
OBJECT
 An entity that has state and behaviour is known as an object.
Ex-: chair, pen ,table , keyboard etc.
 An object can be defined as an instance of a class . A class is a template or
blueprint from which object are created . So , an object is the instance
(result) of a class.
 An object contains an address and takes up some sp[ace in memory .
Objects can communicate without knowing the details of each other’s data
or code.
CLASS
 Collection of objects is called class . It is a logical entity.
 A class can also be defined as a blueprint from
which you can create an individual object
Class doesn’t consume any space.
 A class in java can contain:
 Fields
 Methods
 Constructors
 Blocks
 Nested class and interface
Example of class and object
INHERITANCE
 Inheritance in java is a mechanism in which one object acquires all the
properties and behaviors of a parent object.
 It provides code reusability .
 It is used to achieve runtime polymorphism.
 Types of inheritance in Java
1. Single
2. Multilevel
3. Hierarchical
Example of INHERITANCE
POLYMORPHISM
 If one task is performed in different ways , it is known as polymorphism . For
example : to convince the customer differently , to draw something , for
example , shape , triangle , rectangle , etc.
 In Java, we use method overloading and method overriding to achieve
polymorphism.
 Method Overloading -:
o If a class has multiple methods having same name but different in
parameters, it is known as Method Overloading.
 Method Overriding -:
o If subclass (child class) has the same method as declared in the parent class, it
is known as method overriding in Java.
POLYMORPHISM
Abstraction
 Hiding internal details and showing functionality is known as abstraction .
For example phone call , we don’t know the internal processing.
 Abstraction is a process of hiding the implementation details and showing
only functionality to the user.
 In Java, we use abstract class and interface to achieve abstraction.
ENCAPSULATION
 Binding (or wrapping) code and data together into a single unit are known as
encapsulation. For example, a capsule, it is wrapped with different medicine
 A java class is the example of encapsulation. Java bean is the fully
encapsulated class because all the data members are private here.
 We can create a fully encapsulated class in Java by making all the data
members of the class private.
Method in Java
 A method is a block of code or collection of statements or a set of code
grouped together to perform a certain task or operation.
 The method declaration provides information about method attributes, such
as visibility, return-type, name, and arguments. It has six components that are
known as method header, as we have shown in the following figure
Access Specifier
 Access Specifier:
Access specifier or modifier is the access type of the method. It specifies
the visibility of the method.
 Java provides four types of access specifier:
 Public: The method is accessible by all classes when we use public specifier in our
application.
 Private: When we use a private access specifier, the method is accessible only in
the classes in which it is defined.
 Protected: When we use protected access specifier, the method is accessible
within the same package or subclasses in a different package.
 Default: When we do not use any access specifier in the method declaration, Java
uses default access specifier by default. It is visible only from the same package
only.
Variables
 A variable is the name of a reserved area allocated in memory. In other
words, it is a name of the memory location. It is a combination of "vary
+ able" which means its value can be changed.
 Types of variable
 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. Memory
allocation for static variables happens only once when the class is
loaded in the memory.
Constructor in Java
 In Java, a constructor is a block of codes similar to the method. It is called
when an instance of the class is created.
 At the time of calling constructor, memory for the object is allocated in the
memory.
 A It is a special type of method which is used to initialize the object.
 Every time an object is created using the new() keyword, at least one
constructor is called.
 There are two types of constructor:
a) Default constructor(No argument constructor)
b) Parameterised constructor
Operators
 Operator in Java is a symbol that is used to perform operations. For
example: +, -, *, / etc.
Java Data Types
 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.
Nitish Chaulagai Java1.pptx

Nitish Chaulagai Java1.pptx

  • 1.
    CHHATRAPATI SHAHU JIMAHARAJ UNIVERSITY KANPUR PRESENTATION ON INTRODUCTION TO JAVA PROGRAMMING Presented by -:  Nitish Chaulagai In the guidance of respected sir  Mr. Shivneet Tripathi
  • 2.
    Introduction  Java isa programming language and a platform. Java is a high level, robust, object-oriented and secure programming language.  Java was developed by Sun Microsystems (which is now the subsidiary of Oracle) in the year 1995. James Gosling is known as the father of Java.
  • 3.
    Types of JavaApplication  Standalone Application  Web Application  Enterprise Application  Mobile Application
  • 4.
    Features of Java Object Oriented  Platform Independent  Portable  Interpreted  Robust  Multithreaded etc.
  • 5.
    OOPs (Object OrientedProgramming system)  OBJECT  CLASS  INHERITENCE  POLYMORPHISM  ABSTRACTION  ENCAPSULATION Object-Oriented Programming is a methodology or paradigm to design a program using classes and objects . It simplifies software development and maintenance by providing some concepts-:
  • 6.
    OBJECT  An entitythat has state and behaviour is known as an object. Ex-: chair, pen ,table , keyboard etc.  An object can be defined as an instance of a class . A class is a template or blueprint from which object are created . So , an object is the instance (result) of a class.  An object contains an address and takes up some sp[ace in memory . Objects can communicate without knowing the details of each other’s data or code.
  • 7.
    CLASS  Collection ofobjects is called class . It is a logical entity.  A class can also be defined as a blueprint from which you can create an individual object Class doesn’t consume any space.  A class in java can contain:  Fields  Methods  Constructors  Blocks  Nested class and interface
  • 8.
    Example of classand object
  • 9.
    INHERITANCE  Inheritance injava is a mechanism in which one object acquires all the properties and behaviors of a parent object.  It provides code reusability .  It is used to achieve runtime polymorphism.  Types of inheritance in Java 1. Single 2. Multilevel 3. Hierarchical
  • 10.
  • 11.
    POLYMORPHISM  If onetask is performed in different ways , it is known as polymorphism . For example : to convince the customer differently , to draw something , for example , shape , triangle , rectangle , etc.  In Java, we use method overloading and method overriding to achieve polymorphism.  Method Overloading -: o If a class has multiple methods having same name but different in parameters, it is known as Method Overloading.  Method Overriding -: o If subclass (child class) has the same method as declared in the parent class, it is known as method overriding in Java.
  • 12.
  • 13.
    Abstraction  Hiding internaldetails and showing functionality is known as abstraction . For example phone call , we don’t know the internal processing.  Abstraction is a process of hiding the implementation details and showing only functionality to the user.  In Java, we use abstract class and interface to achieve abstraction.
  • 14.
    ENCAPSULATION  Binding (orwrapping) code and data together into a single unit are known as encapsulation. For example, a capsule, it is wrapped with different medicine  A java class is the example of encapsulation. Java bean is the fully encapsulated class because all the data members are private here.  We can create a fully encapsulated class in Java by making all the data members of the class private.
  • 15.
    Method in Java A method is a block of code or collection of statements or a set of code grouped together to perform a certain task or operation.  The method declaration provides information about method attributes, such as visibility, return-type, name, and arguments. It has six components that are known as method header, as we have shown in the following figure
  • 16.
    Access Specifier  AccessSpecifier: Access specifier or modifier is the access type of the method. It specifies the visibility of the method.  Java provides four types of access specifier:  Public: The method is accessible by all classes when we use public specifier in our application.  Private: When we use a private access specifier, the method is accessible only in the classes in which it is defined.  Protected: When we use protected access specifier, the method is accessible within the same package or subclasses in a different package.  Default: When we do not use any access specifier in the method declaration, Java uses default access specifier by default. It is visible only from the same package only.
  • 17.
    Variables  A variableis the name of a reserved area allocated in memory. In other words, it is a name of the memory location. It is a combination of "vary + able" which means its value can be changed.  Types of variable  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. Memory allocation for static variables happens only once when the class is loaded in the memory.
  • 18.
    Constructor in Java In Java, a constructor is a block of codes similar to the method. It is called when an instance of the class is created.  At the time of calling constructor, memory for the object is allocated in the memory.  A It is a special type of method which is used to initialize the object.  Every time an object is created using the new() keyword, at least one constructor is called.  There are two types of constructor: a) Default constructor(No argument constructor) b) Parameterised constructor
  • 19.
    Operators  Operator inJava is a symbol that is used to perform operations. For example: +, -, *, / etc.
  • 20.
    Java Data Types 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.