0% found this document useful (0 votes)
41 views

Core Java Basics: Presenters: Dinesh Kumar Rajat Srivastava

The document provides an overview of a presentation on Core Java Basics. The agenda includes an introduction to Java covering its history, versions, platform independence, and object-oriented principles. It also covers data types and operators in Java, and an overview of the Eclipse IDE. The introduction section defines Java's platform independence, widespread usage, support for OOP concepts like encapsulation and inheritance, automatic memory management using garbage collection, security features, and support for multithreading.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Core Java Basics: Presenters: Dinesh Kumar Rajat Srivastava

The document provides an overview of a presentation on Core Java Basics. The agenda includes an introduction to Java covering its history, versions, platform independence, and object-oriented principles. It also covers data types and operators in Java, and an overview of the Eclipse IDE. The introduction section defines Java's platform independence, widespread usage, support for OOP concepts like encapsulation and inheritance, automatic memory management using garbage collection, security features, and support for multithreading.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 34

Core Java Basics

Presenters:
Dinesh Kumar
Rajat Srivastava
Agenda

 Java Introduction
 History and versions
 Platform independence
 OOPS

 Data types and Operators

 Overview of Eclipse IDE

 Q&A
Java Introduction

Version control 2.0


Java Introduction

 Platform Independent

 Vastly used ( more than 3 billion devices)

 OOPS support

 Automatic memory management


 Garbage Collection
 No use of pointers

 Secure

 Supports Multi-threading

 Lots of Support from Open Source Community


Version History

• Jan 1996, Codenamed Oak


JDK 1.0 • First stable version of JDK

• Feb 1997
JDK 1.1 • Inner classes, JavaBeans, JDBC, RMI, Reflection etc.

• Dec 1998, Codenamed Playground


J2SE 1.2 • Swing integrated, JIT compiler, Java Plug in, Collections framework etc.

• May 2000, Kestrel


J2SE 1.3 • Hotspot JVM, JNDI integrated etc.
Version History contd…

• Feb 2002, Codenamed Merlin


J2SE 1.4 • Exception chaining, Logging API, JAXP, Java Web start, integrated JAAS etc.

• Sep 2004, Codenamed Tiger


J2SE 5.0 • Generics, Annotations, Autoboxing, Enumerations, Varargs, Enhanced for loop etc.

• Dec 2006, Codenamed Mustang


JAVA SE 6 • Performance improvements, JDBC 4 support, Improved Web service support etc.

• Jul 2011, Codenamed Dolphin


JAVA SE 7 • Small Language changes, support for dynamic languages, new File IO library etc.

• March 2014
JAVA SE 8 • Lambda Expression, Stream API, Date Time API, Base 64, Security, Functional Interface etc.
Version History contd…

• Sep 2017
JAVA SE 9 • Java Modules, JShell (REPL), Http 2clientetc.

• March 2018
JAVA SE 10 • GC interface, Application Data-Class sharing, Local variable type interface etc.

• Sep 2018
JAVA SE 11 • New String methods, Files read/write string, single-file source etc.

• March 2019 (expected)


JAVA SE 12
Platform Independency

.java class files

Compiler
.class Byte Code

JVM JVM JVM

Windows MAC Linux


JVM, JRE and JDK
Java Editions

Java Editions

Java SE Java EE Java ME


Standard Edition Enterprise Edition Micro Edition

Client side Servlets, JSP, Mobile device


standalone apps Server side apps apps
OOPS Concepts

Version control 2.0


Encapsulation

Encapsulation: – Encapsulation is a technique that


binds code and data together into a single unit and An Object A Car
keeps safe from outside interference and misuse.
Model
In encapsulation, the variables of a class will be hidden Data Year of Mft
from other classes, and can be accessed only through Members Color
the methods of their current class. Therefore, it is also Start
known as data hiding. Functions Move
Stop
The java class is the example of encapsulation; a class
defines the data and code (structure and behavior)
that will be shared by a set of objects.
Inheritance

Inheritance: – Inheritance is a technique by which one object


acquires the properties of another object. It provides re-usability of
code and can be used to add additional features to an existing class,
without modifying it.

The class which inherits the properties of other is known as subclass


(derived class, child class) and the class whose properties are
inherited is known as superclass (base class, parent class).
Inheritance Cont…
Types of Inheritance

Single Inheritance
Vehicle

FourWheeler

Multi Level Inheritance Vehicle

FourWheeler

BMW
Types of Inheritance Cont…

Hierarchical Inheritance Vehicle

TwoWheeler FourWheeler

Multiple Inheritance Parent Class 2


Parent Class 1

NOT POSSIBLE IN JAVA


“Can be achieved through
Interfaces”
Child Class
“IS-A” relationship

Vehicle

TwoWheeler FourWheeler

BMW “IS-A” 4-wheeler

BMW
“HAS-A” relationship

Vehicle

TwoWheeler FourWheeler

BMW “HAS-A” MusicSystem

BMW Music System


Aggregation

• Denotes a situation where Object(s) of Class MusicSystem ‘belong to’ Class BMW
• Implies reference from BMW to MusicSystem
• Also implies that object of Class MusicSystem retain an existence independent of
Class BMW.
“HAS-A” relationship

Vehicle

TwoWheeler FourWheeler

BMW “HAS-A” Carburetor

BMW Carburetor
Composition

• A much stronger belonging relationship i.e. Object(s) of Class Carburetor are


‘part of’ a Class BMW object.
• Much ‘stronger’ than aggregation
• objects of Class Carburetor never exist other than as part of Class BMW, i.e.
they have the same ‘lifetime’
• Aggregation Vs Composition in detailed will be explained in further sessions
Polymorphism

Polymorphism: – The Greek meaning of polymorphism is


“many forms”, it is a feature that allows you to define one
common interface that have multiple implementations.

Polymorphism is the ability of an object to take on many


forms. The most common use of polymorphism in OOP
occurs when a parent class reference is used to refer to a
child class object.

Once reference variable for an Object is declared, the type of


a reference variable cannot be changed.

The reference variable can be reassigned to other objects.


The type of the reference variable would determine the
methods that it can invoke on the object.
Polymorphism Cont…

A reference variable can refer to any object of its


declared type or any subtype of its declared type.
A reference variable can be declared as a class or
interface type.

Ability to determine which type to be invoked at


the compile time:
Method Overloading : Compile Time Polymorphism

Ability to select different methods according to the


actual type of an object:
Method Overriding: Run-time Polymorphism
Abstraction

Abstraction: – As per dictionary, abstraction is the quality of


dealing with ideas rather than events.

Consider the case of ATM, complex details such as what


happens when you enter PIN, the protocol your bank server
uses, transaction management are hidden from the user.
Therefore, to withdraw funds you just need to type the PIN,
mention the amount, and hit enter.

Abstraction is a process of hiding the implementation details


from the user, only the functionality will be provided to the
user. In other words, the user will have the information on
what the object does instead of how it does it.

Showing functionality and hide the complexity is known as


abstraction. Abstract class and Interface is used to achieve
abstraction in java.
Abstraction & Encapsulation
Abstraction & Encapsulation
Data types and Operators

Version control 2.0


Data Types

Primitive Data Types


• Byte (1) - Byte data type is an 8-bit signed two's complement integer. First bit is reserved for sign (-/+)
• Short (2) - Short data type is a 16-bit signed two's complement integer. Value is between (-2^15) to (2^15) -1
• Char (2) - char data type is a single 16-bit Unicode character
• Int (4) - Integer data type is a 32-bit signed two's complement integer.
• Long (8) - Long data type is a 64-bit signed two's complement integer
• Float (4) - Example: float f1 = 234.5f
• Double (8) - Default value is 0.0d
• Boolean (not specified) - There are only two possible values: true and false
Data Types Cont…

Reference Data Types


• They are used to access objects.
• These variables are declared to be of a specific type that cannot be changed.
• Class objects and various type of array variables come under reference datatype.
• Default value of any reference variable is null.
• A reference variable can be used to refer any object of the declared type or any compatible type.

• Example: Animal animal = new Cat();

Java Literals
• Literals are represented directly in the code without any computation.
• Literals can be assigned to any primitive type variable.
• Example: int a = 10;
Operators

Athematic Operators Relational Operators


Adds values on either side Checks if the values of two operands are
+ (Addition) == (equal to) equal or not, if yes then condition
of the operator.
becomes true.
Subtracts right-hand
- (Subtraction) operand from left-hand Checks if the values of two operands are
operand. != (not equal to) equal or not, if values are not equal then
condition becomes true.
Multiplies values on either
* (Multiplication) Checks if the value of left operand is
side of the operator.
> (greater than) greater than the value of right operand, if
yes then condition becomes true.
Divides left-hand operand
/ (Division) by right-hand operand. Checks if the value of left operand is less
< (less than) than the value of right operand, if yes
Divides left-hand operand then condition becomes true.

% (Modulus) by right-hand operand and Checks if the value of left operand is


returns remainder. greater than or equal to the value of right
>= (greater than or equal to)
operand, if yes then condition becomes
Increases the value of true.
++ (Increment)
operand by 1. Checks if the value of left operand is less
Decreases the value of than or equal to the value of right
-- (Decrement) <= (less than or equal to)
operand by 1. operand, if yes then condition becomes
true.
Operators Cont…

Logical Operators Assignment Operators


Called Logical AND Simple assignment operator. Assigns values from right side
=
operator. If both the operands to left side operand.
&& (logical and) operands are non-zero, Add AND assignment operator. It adds right operand to the
then the condition += left operand and assign the result to left operand.
becomes true.
Subtract AND assignment operator. It subtracts right operand
-= from the left operand and assign the result to left operand.
Called Logical OR
Operator. If any of the Multiply AND assignment operator. It multiplies right operand
two operands are non- *= with the left operand and assign the result to left operand.
|| (logical or)
zero, then the condition
Divide AND assignment operator. It divides left operand with
becomes true. /= the right operand and assign the result to left operand.

Called Logical NOT Modulus AND assignment operator. It takes modulus using
%=
Operator. Use to two operands and assign the result to left operand.
reverses the logical state <<= Left shift AND assignment operator.
! (logical not) of its operand. If a >>= Bitwise AND assignment operator.
condition is true then &= Right shift AND assignment operator.
Logical NOT operator
^= bitwise exclusive OR and assignment operator.
will make false.
|= bitwise inclusive OR and assignment operator.
Operators Cont…

• Bitwise Operators (&, |, ^, <<, >> etc.)

• Conditional Operators (ternary operator) ( ? : )

• instanceof Operator (check “IS-A” relationship)


Eclipse IDE Introduction

Version control 2.0


Java Installation

Get your hands dirty !!

• Install Java 1.8


• Set JAVA_HOME
• Download Latest Eclipse IDE
– https://www.eclipse.org/downloads/download.php?file=/oomph/epp/2018-12/R/eclipse-inst-win64.exe
Java Hello World !!!

• Run the program in Eclipse IDE


Thank You
Questions?

You might also like