OOPs Through Java Unit-01 Notes (1)
OOPs Through Java Unit-01 Notes (1)
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.
class Simple
{
public static void main(String args[ ])
{
System.out.println("Hello 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 Secured
Java Application:
According to Sun, 3 billion devices run Java.
4. Mobile
5. Embedded System
6. Smart Card
7. Robotics
8. Games, etc.
JAVA JavaScript
Java is object-oriented programming JavaScript is object-oriented scripting
language. language.
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 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.
It models applications as a group of related objects that interact with each other.
Programming starts with the concept of real world objects and classes.
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.
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.
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.
o Runtime Environment
6. Robust:
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.
Compilation Flow:
When we compile Java program using javac tool, java compiler converts the source
code into byte code.