0% found this document useful (0 votes)
38 views28 pages

Java PPT

Uploaded by

cyt22571
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
0% found this document useful (0 votes)
38 views28 pages

Java PPT

Uploaded by

cyt22571
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 28

Core JAVA

By Ritesh Kumar
Content
What is JAVA?
History/About JAVA

What is JAVA?

Where Is JAVA used?

Feature of JAVA

JAVA Virtual Machine

OOP’s Concept
• JAVA is a genral-
History/ purpose and
Object-Oriented
About Programming
Language which is
JAVA developed by the
“Sun Microsoft of
USA” in 1991.
• Originally called
“Oak” by James
Gosling (one of the
• Platform
independence: Java
runs on any device
with a JVM, ensuring
What is compatibility across
different platforms.
JAVA? • Object-oriented: Java's
object-oriented
approach promotes
organized and reusable
code.
• Robust standard
library: Java offers a
comprehensive set of
libraries for various
• Automatic memory
management:
Java's garbage
What is collection simplifies
memory handling,
JAVA? enhancing
application
stability.
• Versatile usage:
Java's wide
adoption across
web, mobile,
• Web Development: Java is
widely used for creating

Where is dynamic and interactive web


applications.

JAVA • Mobile App Development


(Android): Java serves as the

used? primary language for Android


app development, powering
millions of mobile devices
globally.
• Enterprise Software: Java is
extensively utilized in
developing enterprise-level
software systems, including
large-scale applications and
• Scientific Computing:
Java is employed in
scientific computing for
its performance,
Where is reliability, and rich

JAVA
libraries for
mathematical and

used? computational tasks.


• Financial Services: Java
finds widespread use in
the financial industry
for building trading
platforms, banking
applications, and risk
management systems.
• Education: Java is
• Object-Oriented
Feature •

Multi-Threading
Portability
of JAVA • Continous Evolving
• Security
• High Performance
Object-oriented
programming
(OOP) in Java
Object- emphasizes the
Oriented use of objects,
encapsulation,
inheritance,
polymorphism,
abstraction, and
modularity to
create scalable,
maintainable, and
reusable software
Multithreading in
Java facilitates
concurrent task
execution,
Multi- improving

Threading performance by
utilizing available
resources
efficiently.
Synchronization
mechanisms
ensure data
integrity in shared
environments,
optimizing
applications for
Java's portability
ensures that
programs can
Portability run on any
platform with a
JVM, making
applications
independent of
hardware and
operating
systems,
facilitating
widespread
compatibility
Java's evolution has
been marked by
continuous updates,
Evolution introducing features
like collections, Swing
GUI, generics, lambda
expressions, and
modularization to
enhance performance,
security, and
developer
productivity, ensuring
its relevance in
modern software
development.
Java's security,
ensured through
bytecode verification,
sandboxing, and a
Security robust security
manager, facilitates
safe application
execution, while its
support for
encryption and
access control
mechanisms enables
the development of
secure software
Java achieves high
performance through
High Just-In-Time (JIT)
compilation, efficient
Performance memory
management, and
multithreading
support, ensuring
fast execution and
scalability across
diverse hardware
and operating
system
environments.
JAVA • The Java Virtual

Virtual Machine (JVM) is a


crucial component
Machine of the Java
platform,
responsible for
executing Java
bytecode.
JAVA Virtual Machine
It provides a runtime
environment that abstracts
the underlying hardware and
operating system, enabling
Java programs to run
consistently across different
platforms. The JVM includes
components such as the class
loader, bytecode verifier, and
garbage collector, ensuring
Objects are instances
of classes in Java,
OOP’s encapsulating data
Concept and behavior. Java
follows the principles
of encapsulation,
inheritance,
polymorphism, and
abstraction to
facilitate object-
Pillars of OOP’s
Abstraction

Encapsulation

Inheritance

Polymorphism
1. Abstraction
Abstraction in Java refers to the
concept of hiding complex
implementation details and exposing
only essential features of an object. It
allows developers to focus on what an
object does rather
For example, thanan
in Java, how it does it.
abstract
class or interface defines a
blueprint with method signatures
but no implementation details,
enabling subclasses to provide
their own implementations while
adhering to the defined contract.
Abtraction
You interact with your bank account by
depositing money, withdrawing money, and
checking your balance, without needing to
know the intricate details of how these
operations are implemented by the bank.
Similarly, in Java, an abstract class or
interface defines common methods like
deposit(), withdraw(), and getBalance(),
allowing specific types of accounts (e.g.,
savings account, checking account) to
provide their own implementations while
adhering to the defined contract. This
abstraction enables developers to work with
accounts generically, regardless of their
2. Encapsulation
Encapsulation in Java refers to the
bundling of data (attributes) and methods
(behavior) within a class, with the data
hidden from outside access and only
accessible through getter and setter
methods. This protects the data from
unauthorized access
In example, the andencapsulates
Car class modification,the
ensuring
model and data
yearintegrity
attributesand promoting
by declaring them
codeasmaintainability.
private. Access to these attributes is
controlled through public getter and setter
methods (getModel(), setModel(), getYear(),
setYear()), allowing controlled access to the
internal state of the Car object while
maintaining data integrity.
Encapsulation
public class Car {
private String model;
private int year;
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
}
3. Inheritance
Inheritance in Java refers to the
mechanism by which a class (subclass
or child class) can inherit properties
and behaviors from another class
(superclass or parent class). This allows
for
Incode reusethe
example, andDog
promotes the
class inherits
concept of hierarchical
the eat() method from relationships
the Animal
between
class. classes.
By extending the Animal
class, the Dog class gains access to
the eat() method without needing
to redefine it. This demonstrates
the concept of inheritance, where
the Dog class inherits behavior
from its parent class, Animal.
Inheritance
class Animal {
void eat() {
System.out.println("Animal is
eating...");
}
}
class Dog extends Animal {
void bark() {
System.out.println("Dog is barking...");
}
}public class Main {
public static void main(String[] args) {
Dog dog = new Dog();
dog.eat(); // Inherited from Animal
class
dog.bark(); // Defined in Dog class
}
}
4. Polymorphism
Polymorphism in Java allows different
classes to be treated as instances of
the same class type, enabling methods
to behave differently based on the
object they are invoked on.
For instance, in a zoo simulation,
both a Dog and a Cat class can
inherit from an Animal class and
override the makeSound()
method to produce different
sounds when called. This
demonstrates the flexibility and
extensibility of polymorphism in
Java.
Polymorphism
// Parent class (superclass)
class Animal {
void makeSound() {
System.out.println("Animal makes a
sound");
}
}

// Subclass 1
class Dog extends Animal {
@Override
void makeSound() {
System.out.println("Dog barks");
}
}
Polymorphism
// Subclass 2
class Cat extends Animal {
@Override
void makeSound() {
System.out.println("Cat meows");
}
}
public class Main {
public static void main(String[] args) {
// Creating objects of Dog and Cat classes
Animal dog = new Dog();
Animal cat = new Cat();
// Calling the makeSound method on
different objects
dog.makeSound(); // Output: Dog barks
cat.makeSound(); // Output: Cat meows
}
}
Thank
You

You might also like