Docsity

Programming Java Part 1-Java Programming-Lecture Slides, Slides of Java Programming

Partial preview of the text

Download Programming Java Part 1-Java Programming-Lecture Slides and more Slides Java Programming in PDF only on Docsity!

1 Programming Java

COREJAVA

JAVA TECHNOLOGIES

-JAVE SE(STARDARD EDITION)-FORMERLY J2SE
-JAVA EE(ENTERPRISE EDITION)-FORMERLY J2EE
-JAVA ME(MOBILE EDITION)-FORMERLY J2ME(MICRO EDITION)

JVM and Bytecode

4

COREJAVA

Processiong .class file in JVM
JVM running
Applet or
Application

.class file

JIT
COMPILER

machine code

CORE JAVA-OOP CONCEPTS

Types of Programming

-Structured Programming Approach

-Object Oriented Programming Approach

Structures Programming Approach

Mainly function Oriented.. Programs are based on functions.

ExampleC

CORE JAVA-OOP CONCEPTS

What is Object Orientation ??

Similar kinds of Objects which have common properties and behavior can be group together

as a single unit in a class. This concept is known as Object Orientation. This approach is known as Object Orientated Approach.

Example:-

Furniture
Chair Table Book self

CORE JAVA-OOP CONCEPTS

What is Object Orientation ??

Similar kinds of Objects which have common properties and behavior can be group together

as a single unit in a class. This concept is known as Object Orientation. This approach is known as Object Orientated Approach.

Example:-

RealLife Object: State-Variable

Behavior-method

Furniture
Chair Table Book self
Common Behavior:
Keeping something

CORE JAVA-OOP CONCEPTS

Features of 100% OOP Languages:
1) Encapsulation / DataHiding
2) Abstraction
3) Inheritance
4) Polymorphism
5) Dynamic Binding
6) Message Passing

CORE JAVA-OOP CONCEPTS

ENCAPSULATION / DATAHIDING  ABSTRACTION

ENCAPSULATION  Binding or Wrapping of the data and methods into a single unit is called Encapsulation. Encapsulation is used to hide data or protect data from outside access. So this concept is also called data-hiding.

ABSTRACTION  Abstraction refers to the act of representing essential features without including the background details and explanation.

explanation the capsule cures the patient.. But the patient don‘t know what is capsulated inside the capsule…..

CAPSULE

MEDICINE INSIDE THE CAP

COREJAVA

Simple java program

class A

{

public static void main(String arr[]) { System.out.println(―Hello World‖); }

}

COREJAVA

Simple java program

class A { public static void main(String arr[]) { System.out.println(―Hello World‖); } }

Public is a access specifier that declares the method ad unprotected and therefore making it accessible to all other classes.

Static static is a keyowrd ,which declares this method as one that belongs to the entire class and not a part of any objects of the class.

Void does not return anything. docsity.com

COREJAVA

Simple java program

class A { public static void main(String arr[]) Defining main method { System.out.println(―Hello World‖); } }

arr[]takes the values of command line arguments..

Suppose we are giving a b c darr[0]=a,arr[1]=b,arr[2]=c,arr[3]=d

String array as argument

COREJAVA

Compiling java programs
d:\mydirectory>javac A.java
d:\mydirectory>
Running java Programs
d:\mydirectory>java A
Hello World
d:\mydirectory>

CORE JAVA-OOP CONCEPTS

Example Showing Encapsulation

class Encapsulation { private int height; private int width; private int length; public void init() { height=100; width=100; length=100; }