SlideShare a Scribd company logo
1 of 30
INTRODUCTION OF JAVA
PRESENTED BY,
RANJITHAM.N
INTRODUCTION TO JAVA:
• Java was originally developed by James Gosling at Sun
Microsystems .
• It was released in 1995.
• Java applications are typically compiled to Bytecode that can run on
any Java Virtual Machine.
• The language derives much of its syntax from C and C++.
WHAT IS JAVA?
• Java is a computer programming language.
• It is concurrent and written in the concept of Class and Object.
• Purely Object oriented programming.
• Platform independent.
FEATURES OF JAVA:
• Simple
• Secure
• Portable
• Object oriented
• Multithreaded
• High performance
• Dynamic
• interpreted
APPLICATIONS OF JAVA:
• Java program can run on any PC or any operating system.
• Simple and Standalone.
• Mobile application.
• Enterprise.
• Web application
HOW JAVA DIFFER FROM C++:
JAVA PROGRAMMING C++ PROGRAMMING
• Completely object oriented language. • partially object oriented language.
• It is portable. • It is non portable.
• Both compiler and interpreter are
used.
• Only compiler is used.
• Pointer is not used in java. • Pointer is used in c++.
• no global variable is present. • Global variable is present.
• Operator overloading is not possible. • Operator overloading is possible.
• Scope resolution operator is used. • Scope resolution operator is used.
HOW JAVA DIFFER FROM C:
JAVA PROGRAMMING C PROGRAMMING
• Object oriented language. • Function oriented language.
• It is built into long security. • It has limited security.
• Allocating memory by memory
function.
• Allocation of memory by new
function.
• Memory address is through pointers. • Memory address is through reference.
OBJECT ORIETNED PROGRAMMING CONCEPTS:
• Object
• Class
• Data abstraction
• Data encapsulation
• Polymorphism
• Inheritance
• Dynamic binding
• Message communication
OBJECT:
• Basic runtime entity.
• Represent user defined datatype.
• Object interact by sending messages to one another.
CLASS:
• Collection of similar objects.
• User defined datatype.
• Eg: Fruit.
DATA ABSTRACTION:
• The act of representing essential feautures without including the
background details.
• Insulation of the data from direct access by the program is called as
data hiding.
DATA ENCAPSULATION:
• Wrapping up of data and methods into a single unit.
INHERITANCE:
• Objects of one class acquired the properties of objects of another
class.
• Supports the concepts of hierarchical classification.
• Provides the idea of reusability.
• Can add additional features to an existing class without modifying
it.
TYPES OF INHERITANCE:
• Single inheritance
• Multiple inheritance
• Multilevel inheritance
• Hierarchical inheritance
• Hybrid inheritance.
POLYMORPHISM:
• Ability to take more than one form.
• Exhibit different behaviour in different instances.
• Single function name can be used to handle different number an
different types of arguments.
TYPES:
• Dynamic polymorphism.
• Static polymorphism.
DYNAMIC BINDING:
• The code assosiated with the given procedure call is not known
until the time of the call at runtime.
• Assosiated with the polymorphism an inheritance.
• A procedure call associated with a polymorphic reference depends
on the dynamic type of the reference.
MESSAGE COMMUNICATION:
• Program consists of a set of objects that communicate with each
other.
Involves the following basic steps:
• creating classes that define objects and their behaviour .
• creating objects from class definition.
• establishing communications among objects.
DEFINING THE CLASS:
• Once the class type has been defined,we can create the variables.
• Variables are termed as instances of classes.
SYNTAX:
class classname [extends superclassname]
{
fields declaration;
method declaration;
}
METHODS:
• Methods are declared inside the body of the class.
• Methods that are necessary to manipulate the data
contained in the class.
SYNTAX:
type methodname (parameter_list)
{
method_body;
}
METHOD DECLARATION:
• The name of the methods(method name).
• The type of the value the method returns(type).
• A list of parameters(parameter_list).
• The body of the method.
public class Cse
{
public void show()
{
System.out.println("Sample Method ");
}
public static void main(String args[])
{
Cse obj=new Cse1();
obj.show();
}
}
PROGRAM FOR METHOD DECLARATION:
FINALIZER METHODS:
• Java supports a concept called Finalization.
• Java runtime is an automatic garbage collecting system.
• Automatically frees up the memory resources used by the objects.
SYNTAX
protected void finalize()
{
…
...
}
ACCESS SPECIFIERS:
• It is restrict the place where we are using the member of the
class.
• It is used to access the member.
THREE TYPES:
• private
• protected
• public
STATIC:
• Can be called without objects.
• Initialization is not necessary.
• Static function can access only the static variables.
PROGRAM:
class sample
{
public static void main(String[] args) {
display(); }
static void display() {
System.out.println(“hai hello");
} }
STATIC MEMBER:
• The member that are declared static as shown above are static
member.
• Gets memory only in class area at the time of class loading.
• Memory efficient.
Types of static member:
• static variable
• static method
• static block
STATIC MEMBER:
class math
{
Static float mul(float x.float y)
{
return x*y;
}
Static float div(float x,float y)
{
return x/y;
}
}
class math
{
public void static main(string args[])
{
float a=math.mul(4.0.5.0);
float b=math.div(a,2.0);
System.out.println(“b=“+b);
}
}
STATIC VARIABLE
• Gets memory only in class area at the time of class loading.
• Memory efficient.
Class Stu
{
int rollnumber;
string name;
Static string name=“ITS”
Stu( int r.string n)
{
rollnumber=r;
name=n;
}
Void display()
{
System.out.println(“+rollnumber+”
”+name+””+college+”);
}
Public Static void main (string args[])
{
Stu s1=new stu(111,”karan”);
Stu s1=new stu(222”priya”);
S1.display();
S2.display();
}
STATIC METHOD:
• It belongs to the class rare than the object of the class .
• Invoked without the need for creating a instance of class.
• It can access static data member and can change value of it.
class Calculate
{
Static int cube(int x);
return x*x*x;
}
STATIC BLOCK:
 It is used to initialize the static data member.
 Executed before main method at the time of class loading.
Program:
class cse
{
Static { system.out.println(“static block is invoked”);}
public static main(string args[]);
}
CONSTRUCTOR:
• It is a special method where will invoke automatically when the time
of object creation.
Rules:
• Constructor name and the class name should be same.
• It wont have any return type.
• It is used to assign the value to the instance variable.
• It can be with parameter or without parameter..
PROGRAM FOR CONSTRUCTORS:
public class Cube1 {
int length;
int breadth;
int height;
public int getVolume() {
return (length * breadth * height);
}
Cube1() {
length = 10;
breadth = 10;
height = 10;
}
Cube1(int l, int b, int h) {
length = l;
breadth = b;
height = h;
}
public static void main(String[]
args) {
Cube1 cubeObj1, cubeObj2;
cubeObj1 = new Cube1();
cubeObj2 = new Cube1(10, 20, 30);
System.out.println(”Volume of
Cube1 is : ” +
cubeObj1.getVolume());
System.out.println(”Volume of
Cube1 is : ” +
cubeObj2.getVolume());
}
Java2

More Related Content

What's hot

[OOP - Lec 04,05] Basic Building Blocks of OOP
[OOP - Lec 04,05] Basic Building Blocks of OOP[OOP - Lec 04,05] Basic Building Blocks of OOP
[OOP - Lec 04,05] Basic Building Blocks of OOPMuhammad Hammad Waseem
 
Java lec class, objects and constructors
Java lec class, objects and constructorsJava lec class, objects and constructors
Java lec class, objects and constructorsJan Niño Acierto
 
Java OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and ObjectJava OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and ObjectOUM SAOKOSAL
 
L7 inheritance
L7 inheritanceL7 inheritance
L7 inheritanceteach4uin
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functionsMarlom46
 
Java class,object,method introduction
Java class,object,method introductionJava class,object,method introduction
Java class,object,method introductionSohanur63
 
Classes,object and methods java
Classes,object and methods javaClasses,object and methods java
Classes,object and methods javaPadma Kannan
 
Java OOP Programming language (Part 5) - Inheritance
Java OOP Programming language (Part 5) - InheritanceJava OOP Programming language (Part 5) - Inheritance
Java OOP Programming language (Part 5) - InheritanceOUM SAOKOSAL
 
Unit3 inheritance
Unit3 inheritanceUnit3 inheritance
Unit3 inheritanceKalai Selvi
 
Static keyword ppt
Static keyword pptStatic keyword ppt
Static keyword pptVinod Kumar
 
Week9 Intro to classes and objects in Java
Week9 Intro to classes and objects in JavaWeek9 Intro to classes and objects in Java
Week9 Intro to classes and objects in Javakjkleindorfer
 
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions Soumen Santra
 

What's hot (20)

[OOP - Lec 04,05] Basic Building Blocks of OOP
[OOP - Lec 04,05] Basic Building Blocks of OOP[OOP - Lec 04,05] Basic Building Blocks of OOP
[OOP - Lec 04,05] Basic Building Blocks of OOP
 
Java lec class, objects and constructors
Java lec class, objects and constructorsJava lec class, objects and constructors
Java lec class, objects and constructors
 
Unit 3
Unit 3Unit 3
Unit 3
 
Java Methods
Java MethodsJava Methods
Java Methods
 
Java OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and ObjectJava OOP Programming language (Part 3) - Class and Object
Java OOP Programming language (Part 3) - Class and Object
 
L7 inheritance
L7 inheritanceL7 inheritance
L7 inheritance
 
Ch03
Ch03Ch03
Ch03
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functions
 
Java class,object,method introduction
Java class,object,method introductionJava class,object,method introduction
Java class,object,method introduction
 
Classes,object and methods java
Classes,object and methods javaClasses,object and methods java
Classes,object and methods java
 
Java OOP Programming language (Part 5) - Inheritance
Java OOP Programming language (Part 5) - InheritanceJava OOP Programming language (Part 5) - Inheritance
Java OOP Programming language (Part 5) - Inheritance
 
Chap01
Chap01Chap01
Chap01
 
6. static keyword
6. static keyword6. static keyword
6. static keyword
 
Unit3 inheritance
Unit3 inheritanceUnit3 inheritance
Unit3 inheritance
 
Static keyword ppt
Static keyword pptStatic keyword ppt
Static keyword ppt
 
Java static keyword
Java static keywordJava static keyword
Java static keyword
 
Java OO Revisited
Java OO RevisitedJava OO Revisited
Java OO Revisited
 
Object oriented programming With C#
Object oriented programming With C#Object oriented programming With C#
Object oriented programming With C#
 
Week9 Intro to classes and objects in Java
Week9 Intro to classes and objects in JavaWeek9 Intro to classes and objects in Java
Week9 Intro to classes and objects in Java
 
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
 

Similar to Java2 (20)

Java
JavaJava
Java
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptx
 
VB.net&OOP.pptx
VB.net&OOP.pptxVB.net&OOP.pptx
VB.net&OOP.pptx
 
unit 2 java.pptx
unit 2 java.pptxunit 2 java.pptx
unit 2 java.pptx
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
Synapseindia reviews.odp.
Synapseindia reviews.odp.Synapseindia reviews.odp.
Synapseindia reviews.odp.
 
Java 102 intro to object-oriented programming in java
Java 102   intro to object-oriented programming in javaJava 102   intro to object-oriented programming in java
Java 102 intro to object-oriented programming in java
 
Introduction to OOP with java
Introduction to OOP with javaIntroduction to OOP with java
Introduction to OOP with java
 
Net framework
Net frameworkNet framework
Net framework
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
10 - Encapsulation(object oriented programming)- java . ppt
10 - Encapsulation(object oriented programming)- java . ppt10 - Encapsulation(object oriented programming)- java . ppt
10 - Encapsulation(object oriented programming)- java . ppt
 
c++ Unit I.pptx
c++ Unit I.pptxc++ Unit I.pptx
c++ Unit I.pptx
 
Objective-C for iOS Application Development
Objective-C for iOS Application DevelopmentObjective-C for iOS Application Development
Objective-C for iOS Application Development
 
C++ training
C++ training C++ training
C++ training
 
UNIT - IIInew.pptx
UNIT - IIInew.pptxUNIT - IIInew.pptx
UNIT - IIInew.pptx
 
Oops concept on c#
Oops concept on c#Oops concept on c#
Oops concept on c#
 
Lecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptxLecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptx
 
c++ lecture 1
c++ lecture 1c++ lecture 1
c++ lecture 1
 
c++ lecture 1
c++ lecture 1c++ lecture 1
c++ lecture 1
 
c++ introduction
c++ introductionc++ introduction
c++ introduction
 

Recently uploaded

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 

Recently uploaded (20)

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 

Java2

  • 2. INTRODUCTION TO JAVA: • Java was originally developed by James Gosling at Sun Microsystems . • It was released in 1995. • Java applications are typically compiled to Bytecode that can run on any Java Virtual Machine. • The language derives much of its syntax from C and C++.
  • 3. WHAT IS JAVA? • Java is a computer programming language. • It is concurrent and written in the concept of Class and Object. • Purely Object oriented programming. • Platform independent.
  • 4. FEATURES OF JAVA: • Simple • Secure • Portable • Object oriented • Multithreaded • High performance • Dynamic • interpreted
  • 5. APPLICATIONS OF JAVA: • Java program can run on any PC or any operating system. • Simple and Standalone. • Mobile application. • Enterprise. • Web application
  • 6. HOW JAVA DIFFER FROM C++: JAVA PROGRAMMING C++ PROGRAMMING • Completely object oriented language. • partially object oriented language. • It is portable. • It is non portable. • Both compiler and interpreter are used. • Only compiler is used. • Pointer is not used in java. • Pointer is used in c++. • no global variable is present. • Global variable is present. • Operator overloading is not possible. • Operator overloading is possible. • Scope resolution operator is used. • Scope resolution operator is used.
  • 7. HOW JAVA DIFFER FROM C: JAVA PROGRAMMING C PROGRAMMING • Object oriented language. • Function oriented language. • It is built into long security. • It has limited security. • Allocating memory by memory function. • Allocation of memory by new function. • Memory address is through pointers. • Memory address is through reference.
  • 8. OBJECT ORIETNED PROGRAMMING CONCEPTS: • Object • Class • Data abstraction • Data encapsulation • Polymorphism • Inheritance • Dynamic binding • Message communication
  • 9. OBJECT: • Basic runtime entity. • Represent user defined datatype. • Object interact by sending messages to one another. CLASS: • Collection of similar objects. • User defined datatype. • Eg: Fruit.
  • 10. DATA ABSTRACTION: • The act of representing essential feautures without including the background details. • Insulation of the data from direct access by the program is called as data hiding. DATA ENCAPSULATION: • Wrapping up of data and methods into a single unit.
  • 11. INHERITANCE: • Objects of one class acquired the properties of objects of another class. • Supports the concepts of hierarchical classification. • Provides the idea of reusability. • Can add additional features to an existing class without modifying it.
  • 12. TYPES OF INHERITANCE: • Single inheritance • Multiple inheritance • Multilevel inheritance • Hierarchical inheritance • Hybrid inheritance.
  • 13. POLYMORPHISM: • Ability to take more than one form. • Exhibit different behaviour in different instances. • Single function name can be used to handle different number an different types of arguments. TYPES: • Dynamic polymorphism. • Static polymorphism.
  • 14. DYNAMIC BINDING: • The code assosiated with the given procedure call is not known until the time of the call at runtime. • Assosiated with the polymorphism an inheritance. • A procedure call associated with a polymorphic reference depends on the dynamic type of the reference.
  • 15. MESSAGE COMMUNICATION: • Program consists of a set of objects that communicate with each other. Involves the following basic steps: • creating classes that define objects and their behaviour . • creating objects from class definition. • establishing communications among objects.
  • 16. DEFINING THE CLASS: • Once the class type has been defined,we can create the variables. • Variables are termed as instances of classes. SYNTAX: class classname [extends superclassname] { fields declaration; method declaration; }
  • 17. METHODS: • Methods are declared inside the body of the class. • Methods that are necessary to manipulate the data contained in the class. SYNTAX: type methodname (parameter_list) { method_body; }
  • 18. METHOD DECLARATION: • The name of the methods(method name). • The type of the value the method returns(type). • A list of parameters(parameter_list). • The body of the method.
  • 19. public class Cse { public void show() { System.out.println("Sample Method "); } public static void main(String args[]) { Cse obj=new Cse1(); obj.show(); } } PROGRAM FOR METHOD DECLARATION:
  • 20. FINALIZER METHODS: • Java supports a concept called Finalization. • Java runtime is an automatic garbage collecting system. • Automatically frees up the memory resources used by the objects. SYNTAX protected void finalize() { … ... }
  • 21. ACCESS SPECIFIERS: • It is restrict the place where we are using the member of the class. • It is used to access the member. THREE TYPES: • private • protected • public
  • 22. STATIC: • Can be called without objects. • Initialization is not necessary. • Static function can access only the static variables. PROGRAM: class sample { public static void main(String[] args) { display(); } static void display() { System.out.println(“hai hello"); } }
  • 23. STATIC MEMBER: • The member that are declared static as shown above are static member. • Gets memory only in class area at the time of class loading. • Memory efficient. Types of static member: • static variable • static method • static block
  • 24. STATIC MEMBER: class math { Static float mul(float x.float y) { return x*y; } Static float div(float x,float y) { return x/y; } } class math { public void static main(string args[]) { float a=math.mul(4.0.5.0); float b=math.div(a,2.0); System.out.println(“b=“+b); } }
  • 25. STATIC VARIABLE • Gets memory only in class area at the time of class loading. • Memory efficient. Class Stu { int rollnumber; string name; Static string name=“ITS” Stu( int r.string n) { rollnumber=r; name=n; } Void display() { System.out.println(“+rollnumber+” ”+name+””+college+”); } Public Static void main (string args[]) { Stu s1=new stu(111,”karan”); Stu s1=new stu(222”priya”); S1.display(); S2.display(); }
  • 26. STATIC METHOD: • It belongs to the class rare than the object of the class . • Invoked without the need for creating a instance of class. • It can access static data member and can change value of it. class Calculate { Static int cube(int x); return x*x*x; }
  • 27. STATIC BLOCK:  It is used to initialize the static data member.  Executed before main method at the time of class loading. Program: class cse { Static { system.out.println(“static block is invoked”);} public static main(string args[]); }
  • 28. CONSTRUCTOR: • It is a special method where will invoke automatically when the time of object creation. Rules: • Constructor name and the class name should be same. • It wont have any return type. • It is used to assign the value to the instance variable. • It can be with parameter or without parameter..
  • 29. PROGRAM FOR CONSTRUCTORS: public class Cube1 { int length; int breadth; int height; public int getVolume() { return (length * breadth * height); } Cube1() { length = 10; breadth = 10; height = 10; } Cube1(int l, int b, int h) { length = l; breadth = b; height = h; } public static void main(String[] args) { Cube1 cubeObj1, cubeObj2; cubeObj1 = new Cube1(); cubeObj2 = new Cube1(10, 20, 30); System.out.println(”Volume of Cube1 is : ” + cubeObj1.getVolume()); System.out.println(”Volume of Cube1 is : ” + cubeObj2.getVolume()); }