Object Oriented Programming with Java
Syllabus
Unit :- 1
Introduction
Java is a High level , Class based , Object
Oriented Programming (OOP) Language
developed by James Gosling in 1991.
1) James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June
1991. The small team of sun engineers
called Green Team at Sun Microsystem.
2) Initially it was designed for small, embedded systems in electronic appliances like set-top boxes.
3) Firstly, it was called "Greentalk" by James Gosling, and the file
extension was .gt. After that, it was called Oak and was developed as a part of the Green project.
4) Why Oak? Oak is a symbol of strength and chosen as a national tree of many countries like the U.S.A.,
France, Germany, Romania, etc.
5) In 1995, Oak was renamed as "Java" because it was already a trademark by Oak Technologies.
6) Java is an island in Indonesia where the first coffee was produced (called Java coffee). Java name was chosen by James
Gosling while having a cup of coffee nearby his office.
7) Initially developed by James Gosling at Sun Microsystems (which is now a subsidiary of Oracle Corporation) and
released in 1995.
8) JDK 1.0 was released on January 23, 1996.
After the first release of Java, there have been many additional features added to the language. Now Java is
being used in Windows applications, Web applications, enterprise applications, mobile applications, cards, etc.
Each new version adds new features in Java.
The Java Runtime Environment, is a software layer that runs on top of a computer’s operating
system software and provides the class libraries and other resources that a specific Java program
requires to run.
Compilation and Fundamentals
Programming Structures in Java
The access modifiers in Java specifies the accessibility or scope of a field, method, constructor, or class. We can
change the access level of fields, constructors, methods, and class by applying the access modifier on it.
Static Members and Final Members
Object Oriented Programming
A Class is a template or blueprint for creating
Objects; an Object is an Instance of a Class.
An entity that has state and behavior is known as an object e.g., chair, bike, pen, table, car, etc. It can be
physical or logical (tangible and intangible). The example of an intangible object is the banking system
Java, Inheritance is an important pillar of OOP. It is the mechanism in Java by which one class is allowed to inherit the
features(fields and methods) of another class. In Java, Inheritance means creating new classes based on existing ones.
A class that inherits from another class can reuse the methods and fields of that class. In addition, you can add new
fields and methods to your current class as well.
Example:
In the below example of inheritance, class
Employee is a base class, class Engineer is a
derived class that extends the Employee class
and class Test is a driver class to run the
program.
The word polymorphism means having many forms. In simple words, we can define
Java Polymorphism as the ability of a message to be displayed in more than one form.
Packages
In Java, static import concept is introduced in 1.5 version. With the help of static
import, we can access the static members of a class directly without class name or
any object.
For Ex: we always use sqrt() method of Math class by using Math class i.e. Math.sqrt(), but by using static
import we can access sqrt() method directly. According to SUN microSystem, it will improve the code
readability and enhance coding. But according to the programming experts, it will lead to confusion and not
good for programming. If there is no specific requirement then we should not go for static import.