What is Java?
• Java is a class-based object-oriented programming language for
building web and desktop applications.
• It is the most popular programming language and the language of
choice for Android programming.
• Java is a general-purpose, class-based, object-oriented programming
language designed for having lesser implementation dependencies.
• It is a computing platform for application development.
• Java is fast, secure, and reliable.
• Java language developed by Sun Microsystems in early 1990 by
developers James Gosling, Mike Sheridan and Patrick Naughton.
History of Java Programming Language
•The Java language was initially called OAK.
•Originally, it was developed for handling portable devices and set-top
boxes. Oak was a massive failure.
•In 1995, Sun changed the name to “Java” and modified the language to
take advantage of the www (World Wide Web) development business.
Simple:-
Java is a simple programming language because:
• Java technology has eliminated all the difficult
and confusion oriented concepts like pointers,
multiple inheritance in the java language.
• The c,cpp syntaxes easy to understand and easy to
write. Java maintains C and CPP syntax mainly
hence java is simple language.
• Java tech takes less time to compile and execute
the program.
2. Object Oriented:-
Java is object oriented technology because to
represent total data in the form of object. By using
object reference we are calling all the methods,
variables which is present in that class.
3. Platform Independent :-
• Compile the Java program on one OS (operating
system)that compiled file can execute in any
OS(operating system) is called Platform
Independent Nature.
• The java is platform independent language. The
java applications allow its applications compilation
one operating system that compiled (.class) files
can be executed in any operating system.
4. Architectural Neutral: 8. Dynamic:-
Java tech applications compiled in one Java is dynamic technology it follows dynamic memory
Architecture (hardware----RAM, Hard Disk) and allocation(at runtime the memory is allocated) and
that Compiled program runs on any hardware dynamic loading to perform the operations.
architecture (hardware) is called Architectural 9. Distributed:-
Neutral. • By using JAVA technology we are preparing standalone
5. Portable:- applications and Distributed applications.
In Java tech the applications are compiled and executed
• Standalone applications are java applications it doesn’t
need client server architecture. web applications are
in any OS (operating system) and any Architecture
java applications it need client server architecture.
(hardware) hence we can say java is a portable
Distributed applications are the applications the project
language. code is distributed in multiple number of jvm’s.
6. Robust:- 10. Multithreaded:
• Any technology if it is good at two main areas it is • Thread is a light weight process and a small task in large
said to be ROBUST 1. Exception Handling 2. program.
Memory Allocation JAVA is Robust because • If any tech allows executing single thread at a time such
• JAVA is having very good predefined Exception type of technologies is called single threaded
Handling mechanism whenever we are getting technology.
exception we are having meaning full information. • If any technology allows creating and executing more
• AVA is having very good memory management than one thread called as multithreaded technology
system that is Dynamic Memory (at runtime the called JAVA.
memory is allocated) Allocation which allocates 11. Interpretive:-
and deallocates memory for objects at runtime. • JAVA tech is both Interpretive and Completive by using
7. Secure:- Interpreter we are converting source code into byte
code and the interpreter is a part of JVM.
• To provide implicit security Java provide one
12. High Performance:-
component inside JVM called Security Manager.
If any technology having features like Robust, Security,
• To provide explicit security for the Java
Platform Independent, Dynamic and so on then that
applications we are having very good predefined technology is high performance
library in the form of java.Security.package.
• Basic OOPS Concepts in Java with Examples
Object- Oriented Programming is a methodology
or paradigm to design a program using classes
and objects. It simplifies software development
and maintenance by providing some concepts:
• Object
• Class
• Inheritance
• Polymorphism
• Abstraction
• Encapsulation
1. Objects:
Any entity that has state and
behavior is known as an object.
For example, a chair, pen, table,
keyboard, bike, etc. It can be
physical or logical.
• An Object can be defined as an
instance of a class. An object
contains an address and takes up
some space in memory.
• Objects can communicate
without knowing the details of
each other's data or code.
• The only necessary thing is the
type of message accepted and
the type of response returned by
the objects.
2. Classes:
• A class is a ‘data-type’ and an object as a ‘variable’ of 4. Data Abstraction:
that type. Any number of objects can be created after • Abstraction refers to the act of representing essential
a class is created. features without including the background details or
explanations.
• The collection of objects of similar types is termed as
a class. For Example, apple, orange, and mango are • Classes use the concept of abstraction and defined as
the objects of the class Fruit. a list of abstract attributes such as size, weight and
cost , and functions to operate on these attributes.
• Classes behave like built-in data types of a
programming language but are user-defined data • Sometimes the attributes are called members and
types. functions called methods or members functions.
• A class can also be defined as a blueprint from which
• Since the classes use the concept of data abstraction,
you can create an individual object. they are known as Abstract data types(ADT).
• Hiding internal details and showing functionality is
• Class doesn't consume any space.
known as abstraction.
3. Data Encapsulation
• For example phone call, we don't know the internal
• The wrapping up of the data and methods into the processing.
single unit is known as encapsulation.
• In Java, we use abstract class and interface to achieve
• The data is accessible only to those methods, which abstraction
are wrapped in the class, and not to the outside
world.
5. Inheritance:
• This insulation of data from the direct access of the
program is called data hiding.
• Inheritance is the process by which objects of one
class acquire some properties of objects of another
• Encapsulation of the object makes it possible for the class.
objects to be treated like ‘black boxes’ that perform a
Types of Inheritance
specific task without any concern for internal
implementation. • Single
• A java class is the example of encapsulation. Java • Multiple
bean is the fully encapsulated class because all the • Multilevel
data members are private here. • Hybrid
6. Polymorphism :
• Polymorphism is an important OOP
concept;
• Polymorphism means the ability to
take many forms. For Example, an
operation may give different
answers in different instances.
• If we add two numbers, the answer
would be a sum.
• If we add two strings the answer
would be a concatenated string.
• A single function name can be used
to perform different tasks, but the
function should have different
number of arguments or different
types of arguments.
• Polymorphism is extensively used in
implementing inheritance.