icon

Learn Hub


home   Html   Css   JavaScript   React js   C   C++   Python   MySQL  Java   Swift            

java

Java


What is Java?


Developed by Sun Microsystems in 1995, Java is a highly popular, object-oriented programming language. This platform independent programming language is utilized for Android development, web development, artificial intelligence, cloud applications, and much more.

Basic terminologies in Java


Class:The class is a blueprint (plan) of the instance of a class (object). It can be defined as a logical template that share common properties and methods.
Object:The object is an instance of a class. It is an entity that has behavior and state.
Method:The behavior of an object is the method.
Instance variables:Every object has its own unique set of instance variables. The state of an object is generally created by the values that are assigned to these instance variables.

Java Data Types

Java has two categories in which data types are segregated
1.Primitive Data Type: such as boolean, char, int, short, byte, long, float, and double
2.Non-Primitive Data Type or Object Data type: such as String, Array, etc.

data-types_java

Operators in Java


Operators in Java are the symbols used for performing specific operations in Java. Operators make tasks like addition, multiplication, etc which look easy although the implementation of these tasks is quite complex.
  1. Arithmetic Operators
  2. Unary Operators
  3. Assignment Operator
  4. Relational Operators
  5. Logical Operators
  6. Ternary Operator
  7. Bitwise Operators
  8. Shift Operators
  9. instance of operator

Types of Variables in java


Now let us discuss different types of variables which are listed as follows:
types

Arrays in java


An array can contain primitives (int, char, etc.) and object (or non-primitive) references of a class, depending on the definition of the array. In the case of primitive data types, the actual values might be stored in contiguous memory locations (JVM does not guarantee this behavior). In the case of class objects, the actual objects are stored in a heap segment. To learn more about Java Array, go through Java programming course here.
arrays

Classes and Objects in Java

Java Classes

A class in Java is a set of objects which shares common characteristics/ behavior and common properties/ attributes. It is a user-defined blueprint or prototype from which objects are created. For example, Student is a class while a particular student named Ravi is an object.

Java Objects

An object in Java is a basic unit of Object-Oriented Programming and represents real-life entities. Objects are the instances of a class that are created to use the attributes and methods of a class.

Difference between Java Class and Objects

Class Object
Class is the blueprint of an object. It is used to create objects. An object is an instance of the class.
No memory is allocated when a class is declared. Memory is allocated as soon as an object is created.
A class is a group of similar objects. An object is a real-world entity such as a book, car, etc.
Class is a logical entity. An object is a physical entity.
A class can only be declared once. Objects can be created many times as per requirement.
An example of class can be a car. Objects of the class car can be BMW, Mercedes, Ferrari, etc.

Access Modifiers in Java

There are four types of access modifiers available in Java:
  1. Default – No keyword required
  2. Private
  3. Protected
  4. Public
modifiers

Four Main Object Oriented Programming Concepts of Java

Packages In Java

Package in Java is a mechanism to encapsulate a group of classes, sub packages and interfaces. Packages are used for:

Know More About Java icon