Java
Topics
• What is java?
• Introduction
• Classes
• What is class?
• Output statement
• Createing a class
• Variables & methods
• access specifiers
Topics
• java & c++ between differences
• java advantages
• java disadvantages
• conclusion
What is java?
• Java is general purpose high level
programming language developed by
”SunMicrosystems”. A small team of
engineers, known as the Green Team,
initiated the language in 1991. Java was
originally called OAK, and was designed
for handheld devices and set-top boxes.
Oak was unsuccessful, so in 1995 Sun
changed the name to Java.
Introduction
• write the source code and save it with the
name of the class and the”extension.java”
• switch to the “MS-DOS” prompt and then
to the folder where you save the source
code.
• set the path to the folder
• c:programjavajdk 1:bin;
• using DOS commands path
Introduction
• compile the source code using the
compiler
Syntax:- javac filename.java
• excute the byte code using the integer
present
Syntax:- java byte code & file name
Output statement
• the capital statement in java
system.out.println() meaning are to print a
variable value
Syntax:-
System.out.print(“text”/variable);
System.out.printf(“text”/variable);
System.out.println(“text”/variable);
Structure of java program
Syntax:-
class name
{
Public static void main(string args[])
{
--------------
--------------
}
}
Classes
A class provide the basis for encapsulation it
helps you bind data and code into a
simngle unit
What is class ?
A reserved keyword with which we great
classes
What is variables and methods?
Specified a list of instance variables
Specified a list of member methods
Access specifiers
• it can be either private or public default is
public
Private members:-
The members declered as private cannot be
access from outside the class
Public members:-
The members declered as public can be
access from outside the class
Example programs
Class deepika
{
Public static void main(string args[])
{
System.out.println(“hello”);
System.out.println(“how r u”);
}
}
Differences b/w java & c++
• c++ :-
• Extends C with
object-oriented programming and
generic programming. C code can most
properly be used.
• Compatible with C source code, except
for a few corner cases.
• Native unsigned arithmetic support.
• Compile-time templates. Allows for Turing
complete meta-programming
Differences b/w java & c++
• java :
• strongly influenced c++/c syntax
• provides the java native interface and
recently java native access as a way to
directly c++/c codes
• runs on a virtual machine
• Is reflective, allowing metaprogramming
and dynamic code generation at runtime.
Advantages of java
• java is a platform-independent
• java is distributed
• java is interpreted
• java is distributed
• java is secure
• java is robust
• java is multitreded
Disadvantages of java
• Performance
• Look and Feel
• Single-paradigm language
Createing a object
Once aclass you can then create as many
object as you want belonging to the
variables of aclasses in fact object are
classes other term instances of a class
Conclusion
• Java offers the real possibility that most
programs can be written in a type-safe
language. However, for Java to be broadly
useful, it needs to have more expressive
power than it does at present.
• The appendices that follow present a
more detailed specification of our
extensions to the Java language and to
the Java virtual machine
JAVA INTRODUCTION
JAVA INTRODUCTION

JAVA INTRODUCTION

  • 1.
  • 2.
    Topics • What isjava? • Introduction • Classes • What is class? • Output statement • Createing a class • Variables & methods • access specifiers
  • 3.
    Topics • java &c++ between differences • java advantages • java disadvantages • conclusion
  • 4.
    What is java? •Java is general purpose high level programming language developed by ”SunMicrosystems”. A small team of engineers, known as the Green Team, initiated the language in 1991. Java was originally called OAK, and was designed for handheld devices and set-top boxes. Oak was unsuccessful, so in 1995 Sun changed the name to Java.
  • 5.
    Introduction • write thesource code and save it with the name of the class and the”extension.java” • switch to the “MS-DOS” prompt and then to the folder where you save the source code. • set the path to the folder • c:programjavajdk 1:bin; • using DOS commands path
  • 6.
    Introduction • compile thesource code using the compiler Syntax:- javac filename.java • excute the byte code using the integer present Syntax:- java byte code & file name
  • 7.
    Output statement • thecapital statement in java system.out.println() meaning are to print a variable value Syntax:- System.out.print(“text”/variable); System.out.printf(“text”/variable); System.out.println(“text”/variable);
  • 8.
    Structure of javaprogram Syntax:- class name { Public static void main(string args[]) { -------------- -------------- } }
  • 9.
    Classes A class providethe basis for encapsulation it helps you bind data and code into a simngle unit
  • 10.
    What is class? A reserved keyword with which we great classes
  • 11.
    What is variablesand methods? Specified a list of instance variables Specified a list of member methods
  • 12.
    Access specifiers • itcan be either private or public default is public Private members:- The members declered as private cannot be access from outside the class Public members:- The members declered as public can be access from outside the class
  • 13.
    Example programs Class deepika { Publicstatic void main(string args[]) { System.out.println(“hello”); System.out.println(“how r u”); } }
  • 14.
    Differences b/w java& c++ • c++ :- • Extends C with object-oriented programming and generic programming. C code can most properly be used. • Compatible with C source code, except for a few corner cases. • Native unsigned arithmetic support. • Compile-time templates. Allows for Turing complete meta-programming
  • 15.
    Differences b/w java& c++ • java : • strongly influenced c++/c syntax • provides the java native interface and recently java native access as a way to directly c++/c codes • runs on a virtual machine • Is reflective, allowing metaprogramming and dynamic code generation at runtime.
  • 16.
    Advantages of java •java is a platform-independent • java is distributed • java is interpreted • java is distributed • java is secure • java is robust • java is multitreded
  • 17.
    Disadvantages of java •Performance • Look and Feel • Single-paradigm language
  • 18.
    Createing a object Onceaclass you can then create as many object as you want belonging to the variables of aclasses in fact object are classes other term instances of a class
  • 19.
    Conclusion • Java offersthe real possibility that most programs can be written in a type-safe language. However, for Java to be broadly useful, it needs to have more expressive power than it does at present. • The appendices that follow present a more detailed specification of our extensions to the Java language and to the Java virtual machine