Java OOP

Java programming is a general-purpose high-level programming language and computing platform released by Sun Microsystems in 1995. Almost all applications and websites work with java in the current time, and more are created day by day by using this technology. Java is a secure, fast, and reliable programming language. It is using in-game consoles to scientific supercomputers, laptops to data centers and cell phones to the Internet.

What is Java

Java Programmings Used for

It is very popular and has covered this field from the early 2000s until the present.  Java has been used in different applications. Some important are listed below:

  • Banking: Java is used to deal with transaction management.
  • Information Technology: It is designed to solve implementation dependencies.
  • Retail: Applications that you see in a store that is completely written in Java.
  • Android: All Android applications are written in Java or Java API.
  • Financial services: Server-side applications are written in Java.
  • Stock market: Algorithms to track the investment of the company.
  • Big Data: Hadoop MapReduce framework is written in this language.
  • Scientific and Research Community: It is used to deal with a huge amount of data.

History of Java Programmings

Java is developed by James Gosling and his team named Mike Sheridan and Patrick Naughton in 1995 for Sun Microsystems for digital devices such as televisions, set-top boxes, etc.

What is Java Programmings

Java is an object-oriented language similar to C++ with advanced and simplified features. It is free to access and can be run on all platforms.

What is java

  • Concurrent: you can execute many statements at a time instead of sequentially executing it.
  • Class-based:  It is a class-based object-oriented programming language.
  • Independent: “Write once, Run anywhere” It is independent OOP language.

Features of Java Programmings

Simple: Java removing all the complexities which were in C++ such as pointers, operator overloading.

Portable: Java is portable object-oriented language which means that applications written in java can be easily ported to another platform.

Object-oriented: Everything is considered to be an “object” every object passes state to another object to complete execution.

Secured: After compilation code is converted in bytecode, which is not readable by a human. It does not use an explicit pointer and run the programs inside the sandbox. It enables to develop virus-free, tamper-free applications.

Dynamic: It has the ability to adapt to an evolving environment that supports dynamic memory allocation and in this way memory wastage is reduced.

Robust: Java eliminates errors as it checks the code during compile and runtime.

High Performance: Through the use of bytecode java performance is very high because bytecode easily translated into native machine code.

Interpreted: Java provides a run-time environment.

Components in Java Programmings

  • JVM (Java Virtual Machine)
  • JRE (Java Runtime Environment)
  • JDK(Java Development Kit)

Table of Contents

What is an Object

Object in OOPs
Object: is a collection of data and its behavior (known as methods).

Objects have two characteristics:

  • states
  • behaviors.

states and behaviors Examples are given below
Example 1:
Object: House
State: Address, Color, Rooms, stories
Behavior: Open gate, close gate

So if we have to write a class based on states and behaviors of House. We can do it like this: States can be represented as instance variables and behaviors as methods of the class. We try to understand this concept with a coding example.
class House {
   String address;
   String color;
   integer Rooms;
   integer Stories;
   double are;
   void openDoor() {
      // code
   }
   void closeDoor() {
      // code 
   }
 ...
 ...
}

Example 2:
In this example, we take a car as an object
Object: Car
State: Color, Brand, Model, Weight
Behavior: Break, Accelerate, Gear change, Slow Down.

Note: As we know that the behaviors of an object, can be represented by variables and methods in the related class.

Characteristics of Objects:

There are three main characteristics of Objects these are:

  • Abstraction
  • Encapsulation
  • Message passing

Abstraction: Abstraction is a process that shows only “relevant” data and “hides” unnecessary details of an object.

Encapsulation: Encapsulation simply means binding object state(fields) and behavior (methods) together. If we are creating a class, it means that we are doing encapsulation.

Message passing
Message passing in Java means sending an object i.e. message from one thread to another thread. An application may have many objects and a single object in nothing if it does not interact with other objects. So, one object interacts with another object by invoking methods on that object. It is also called as Method Invocation.

Method Invocation is used when threads do not have shared memory

OOps concepts message passing

Class in OOPs

Classes, In object-oriented programming, a class is considered a blueprint for creating objects (a particular data structure), providing initial values for state (member variables or attributes), and implementations of behavior (member functions or methods). The class is a blueprint that defines the nature of a future object.

 

What is a Constructor

Object-Oriented Programming features

Abstraction

Encapsulation



Inheritance


Polymorphism

Abstract Class and methods in OOPs Concepts

Abstract Class


Interfaces in Java


Example of Interface:

Generalization and Specialization:

Access Specifiers

 

In computer science, OOP or Object Oriented Programming is a technique that makes programming secure and more easer by arranging data into different classes. Source code was often convoluted and hard to maintain before OOP. Smalltalk is the inventor of OOP introduced in 1972, and later, in 1979, the most well-known OOP language, C++, introduces and become very famous. Well, known OOP languages, including Objective-C, Python, Java, and PHP are using to write computer applications. Main three concepts of OOP are:

  • classes
  • inheritance
  • polymorphism

Object Oriented Programming

The “object” in an Object Oriented Programing language is an instance or specific type of the class. According to structure, each Object has a structure related to other objects in the class, but it can be allocated individually. An object can be called a method or function, particularly to that object. The important features which are helping to design the object-oriented programming and design is given below:

  • Development over the designed programming.
  • Importance of data rather than algorithms.
  • Procedural abstraction is perfected by data abstraction in OOP.
  • Data and associated processes are unified in Object Oriented Programming.

Features of Object Oriented Programming

There twelve fundamental features of OOP are given below.

  • Encapsulation
  • Data Abstraction
  • Inheritance
  • Polymorphism
  • Extensibility
  • Persistence
  • Delegation
  • Generality
  • Object Concurrency
  • Event Handling
  • Multiple Inheritance
  • Message Passing

Object Oriented Programming allows working with classes and objects as well as the implementation. It uses the main four fundamental Object Oriented Principles. These fundamental concepts are given below

  • Encapsulation is used to hide unnecessary details in classes and deliver a simple and clear interface.
  • Inheritance explains how the class hierarchies develop code readability and support to the reused functionality.
  • Data Abstraction deals with objects, their important features and ignores all other details.
  • Polymorphism deals to work with a different object in a related manner.

Conclusion

All the features and principles of OOP are explained clearly with examples in the above task as it also describes what is Object Oriented Programming language and its characteristics.