Вы находитесь на странице: 1из 7

JVM

OOP with JAVA

Basic Syntax

Introduction

Prodip Kumar (M.Sc. Computer Science)


1

Cover
INTRODUCTION TO JAVA
Java programming language was originally
developed by Sun Microsystems which was
initiated by James Gosling and released in 1995
as core component of Sun Microsystems' Java
platform (Java 1.0 [J2SE]).
OOP with JAVA

Introduction
Basic Syntax

Cover
The language, initially called ‘Oak’
after an oak tree that stood outside Gosling's
office,

later being renamed as Java.

Prodip Kumar (M.Sc. Computer Science) 2


Basic Syntax

When we consider a Java program, it can be defined as a collection of objects


that communicate via invoking each other's methods. Let us now briefly look
into what do class, object, methods, and instance variables mean.

 Object - Objects have states and behaviors. Example: A dog has states -
color, name, breed as well as behavior such as wagging their tail, barking,
OOP with JAVA

Introduction
Basic Syntax
eating. An object is an instance of a class.

Cover
 Class - A class can be defined as a template/blueprint that describes the
behavior/state that the object of its type supports.

 Methods - A method is basically a behavior. A class can contain many


methods. It is in methods where the logics are written, data is
manipulated and all the actions are executed.

 Instance Variables - Each object has its unique set of instance variables.
An object's state is created by the values assigned to these instance
variables.
Prodip Kumar (M.Sc. Computer Science) 3
OBJECT ORIENTED PROGRAMMING WITH JAVA

Object Oriented programming is a programming style


which is associated with the concepts like class, object,

OOP with JAVA

Introduction
Basic Syntax
Inheritance, Encapsulation, Abstraction,

Cover
Polymorphism.
Most popular programming languages As Java being
the most sought-after skill. An object-based
application in Java is based on declaring classes,
creating objects from them and interacting
between these objects.
Prodip Kumar (M.Sc. Computer Science) 4
JAVA VIRTUAL MACHINE (JVM)

JVM is a engine that provides runtime environment to drive


the Java Code or applications. It converts Java bytecode into
machines language. JVM is a part of JRE(Java Run
Environment). It stands for Java Virtual Machine.

OOP with JAVA

Introduction
Basic Syntax
 In other programming languages, the compiler produces

Cover
JVM
machine code for a particular system. However, Java
compiler produces code for a Virtual Machine known as Java
Virtual Machine.
 First, Java code is complied into bytecode. This bytecode
gets interpreted on different machines

Prodip Kumar (M.Sc. Computer Science) 5


JAVA IS PLATFORM INDEPENDENT

Java is a platform independent programming


language, Because when you install jdk software on

Platform Independent
your system then automatically JVM are installed on

OOP with JAVA

Introduction
Basic Syntax
your system. For every operating system separate

Cover
JVM
JVM is available which is capable to read the .class file
or byte code. When we compile your Java code then
.class file is generated by javac compiler these codes
are readable by JVM and every operating system have
its own JVM so JVM is platform dependent but due to
JVM java language is become platform independent.

Prodip Kumar (M.Sc. Computer Science) 6


First Java Program

public class MyFirstJavaProgram


{
public static void main(String []args)
{

Platform Independent
Sample Program

OOP with JAVA


System.out.println("Hello World"); // prints Hello World

Introduction
Basic Syntax
}

Cover
JVM
}

Open notepad and add the code as above.

Save the file as: MyFirstJavaProgram.java.

Open a command prompt , Type 'javac MyFirstJavaProgram.java' and press


enter to compile your code.

Now, type ' java MyFirstJavaProgram ' to run your program.


Prodip Kumar (M.Sc. Computer Science) 7

Вам также может понравиться