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

OOPs Through Java Unit-01 Notes (1)

Java is an object-oriented, class-based programming language developed by Sun Microsystems in 1995, known for its portability and security, allowing it to run on various platforms. The document outlines the history of Java, its features, and differences between Java and JavaScript, as well as the principles of Object-Oriented Programming. It also explains how to write and execute Java programs, highlighting its application in various domains such as web, mobile, and enterprise solutions.

Uploaded by

amitkum73208
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

OOPs Through Java Unit-01 Notes (1)

Java is an object-oriented, class-based programming language developed by Sun Microsystems in 1995, known for its portability and security, allowing it to run on various platforms. The document outlines the history of Java, its features, and differences between Java and JavaScript, as well as the principles of Object-Oriented Programming. It also explains how to write and execute Java programs, highlighting its application in various domains such as web, mobile, and enterprise solutions.

Uploaded by

amitkum73208
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

JAVA

Unit 1: Principles of Object-Oriented


Programming with Introduction to java
Introduction to Java:
Java is an object-oriented, class-based, secured and general-purpose computer-
programming language.

Java is a high-level programming language, object-oriented and secure


programming language.

Java was developed by Sun Microsystems in the year 1995.

James Gosling is known as the father of Java.

Before Java, its name was Oak. Since Oak was already a registered company, so
James Gosling and his team changed the Oak name to Java.

Java runs on a variety of platforms, such as Windows, Mac OS, and UNIX OS.
Java is guaranteed to be WORA means Write Once, Run Anywhere.

Example with Java Programming:

class Simple
{
public static void main(String args[ ])
{
System.out.println("Hello Java");
}
}

Save (above program): demo.java

Compile (Syntax): javac file_name.java


Example: javac demo.java
Execute/Run (Program)-Syntax: java class_name
Example: java Simple
An Overview/History of Java:
 Java was originally designed for interactive television, but it was too
advanced technology for the digital cable television industry at the time.
 The history of Java starts with the Green Team. Java team members (also
known as Green Team), initiated this project to develop a language for
digital devices such as set-top boxes, televisions, etc.
 it was suited for internet programming.
 Currently, Java is used in internet programming, mobile devices, games, e-
business solutions, etc.
 JDK 1.0 released in (January 23, 1996).
 Now Java is being used in Windows applications, Web applications, enterprise
applications, mobile applications, cards, etc.

Java Version History:

1. JDK Alpha and Beta (1995)

2. JDK 1.0 (23rd Jan 1996)

3. JDK 1.1 (19th Feb 1997)

4. J2SE 1.2 (8th Dec 1998)

5. J2SE 1.3 (8th May 2000)

6. J2SE 1.4 (6th Feb 2002)

7. J2SE 5.0 (30th Sep 2004)

8. Java SE 6 (11th Dec 2006)

9. Java SE 7 (28th July 2011)

10. Java SE 8 (18th Mar 2014)

11. Java SE 9 (21st Sep 2017)

12. Java SE 10 (20th Mar 2018)

13. Java SE 11 (2020) [Current version of Java].

Java Applets:
Applet is a special type of program that is embedded in the webpage to generate the
dynamic content. It runs inside the browser and works at client side.

Advantage of Applets:

o It works at client side so less response time.

o Secured
Java Application:
According to Sun, 3 billion devices run Java.

There are many devices where Java is currently used.

Some of them are as follows:

1. Desktop Applications such as acrobat reader, media player, antivirus, etc.

2. Web Applications such as irctc.co.in, facebook.com, flipkart.com etc.

3. Enterprise Applications such as banking applications.

4. Mobile

5. Embedded System

6. Smart Card

7. Robotics

8. Games, etc.

Difference between Java & Java Script:

JAVA JavaScript
Java is object-oriented programming JavaScript is object-oriented scripting
language. language.

Java programmes are platform JavaScript code run only on web


independent. browsers.

Java objects are class based. JavaScript objects are prototype based.

Java files have ".java" extension. JavaScript files have extension ".js".

These files are converted to bytecode These are not compiled instead they are
which are executed by JVM. interpreted by the JavaScript interpreter
which is present in every browser.

Java is a standalone language. JavaScript is contained in web pages.

Java is mainly used for Android JavaScript is mainly used for web
application development. development.
Features of OOP (Object Oriented Programming):
Object means a real-world entity such as a pen, chair, table, computer, watch, etc.

Object-Oriented Programming is a methodology to design a program using


classes and objects.

It models applications as a group of related objects that interact with each other.

Example: Mobile Phone interfaces.

Programming starts with the concept of real world objects and classes.

It simplifies software development and maintenance by providing some concepts:

1. Object
2. Class
3. Inheritance
4. Polymorphism
5. Abstraction
6. Encapsulation

1. Object: Any entity that has state and behavior is known as an object. For
example, a chair, pen, table, keyboard, bike, etc.
2. Class: Collection of objects is called class.
A class can also be defined as a blueprint from which you can create an
individual object.

3. Inheritance: When one object acquires all the properties and behaviors of
a parent object, it is known as inheritance.
In OOP one object inherit the properties of another object.
It provides code reusability.

4. Polymorphism: If one task is performed in different ways, it is known as


polymorphism. For example: to convince the customer differently, to draw
something, for example, shape, triangle, rectangle, etc.
In Java, we use method overloading and method overriding to achieve
polymorphism.
Polymorphism is the process of using same method name by multiple classes and
redefines methods for the derived classes.

5. Abstraction: Hiding internal details and showing functionality is known as

abstraction. For example: phone call, we don't know the internal processing.
In Java, we use abstract class and interface to achieve abstraction.

6. Encapsulation: Hiding the implementation details of the class from the user
through an object’s methods is known as data encapsulation.
Binding (or wrapping) code and data together into a single unit are known as
encapsulation. For example, a capsule, it is wrapped with different medicines.
A java class is the example of encapsulation.
Features of JAVA:
The primary objective of Java programming language creation was to make
it portable, simple and secure programming language.
The features of Java are also known as java buzzwords.
A list of most important features of Java language is given below:

1. Simple

2. Object-Oriented

3. Portable

4. Platform independent

5. Secured

6. Robust

7. Architecture neutral

8. Interpreted

9. High Performance

10. Multithreaded

11. Distributed

12. Dynamic

1. Simple:
 Java is very easy to learn, and its syntax is simple, clean and easy to
understand.

 Java syntax is based on C++ (so easier for programmers to learn it


after C++).

 There is no need to remove unreferenced objects because there is an


Automatic Garbage Collection in Java.

2. Object-Oriented:
 Java is an object-oriented programming language. Everything in Java
is an object. Object-oriented means we organize our software as a
combination of different types of objects that incorporates both data
and behavior.
 Object-oriented programming (OOPs) is a methodology that simplifies
software development and maintenance by providing some rules.
 Basic concepts of OOPs are:

o Object

o Class

o Inheritance

o Polymorphism

o Abstraction

o Encapsulation

3. Portable:
 Java is portable because it facilitates you to carry the Java bytecode to
any platform.

4. Platform independent
 Java is platform independent because it is different from other
languages like C, C++, etc.
 which are compiled into platform specific machines while Java is a
write once, run anywhere language.
 A platform is the hardware or software environment in which a
program runs.
 There are two types of platforms software-based and hardware-based.
Java provides a software-based platform.

 It has two components:

o Runtime Environment

o API (Application Programming Interface)

 Java code can be run on multiple platforms, for example, Windows,


Linux, Sun Solaris, Mac/OS, etc.
 Java code is compiled by the compiler and converted into bytecode.
 This bytecode is a platform-independent code because it can be run on
multiple platforms, i.e., Write Once and Run Anywhere (WORA).
5. Secured:

 Java is best known for its security.


 Java is secured because:
o No explicit pointer
o Java Programs run inside a virtual machine
 Class loader: Class loader in Java is a part of the Java Runtime
Environment (JRE) which is used to load Java classes into the Java
Virtual Machine dynamically.
 Bytecode Verifier.

6. Robust:

 Robust simply means strong.


 Java is robust because:

o It uses strong memory management.

o There is automatic garbage collection in java which runs on the


Java Virtual Machine to get rid of objects which are not being used
by a Java application anymore.

o There are exception handling and the type checking mechanism in


Java. All these points make Java robust.
7. Architecture neutral:
 Java is architecture neutral because there are no implementation
dependent features.
 for example: it occupies 4 bytes of memory for both 32 and 64-bit
architectures in Java.

8. Interpreted:
 Java byte code is translated into machine code.
9. High Performance:
 Java is faster than other programming languages because Java
bytecode is "close" to Source code.
10. Multithreaded:
 A thread is like a separate program, or light weight process, executing
concurrently.

 Threads are important for multi-media, Web applications, etc.


11. Distributed:
 Java is distributed because it facilitates users to create distributed
applications in Java.

 This feature of Java makes us able to access files by calling the


methods from any machine on the internet.
12. Dynamic:
 Java is a dynamic language. It supports dynamic loading of
classes. It means classes are loaded on demand.
 Java supports dynamic compilation and automatic memory
management (garbage collection).
JAVA
How to Write & execute program in
JAVA language:

Compilation Flow:

When we compile Java program using javac tool, java compiler converts the source
code into byte code.

You might also like