- Java Blogs -

Java Tutorial Guide For Beginners

Java Tutorial Guide For Beginners

Java is one of the most popular and in-demand programming languages. A number of software applications are developed using Java due to its leveraging features. Though it is quite easy to learn and this tutorial is written for those who want to learn the basics of Java programming.  It is basically a programming guide for beginners. It can help you to learn Java programming and covers following listed points related to Java:

  • Introduction to Java
  • Setting up Java Environment
  • Object Oriented or OOPS Concepts

Java has a number of classes and methods. We have described only a few aspects of this language still you may find many new advanced concepts in Java language. Through this object-oriented programming language, a number of real-world applications can be developed. Java Tutorial Guide For Beginners

Introduction To Java

Java is a high-level programming language that was originally developed by Sun Microsystem in the year 1995. It is a platform independent and object-oriented language. As the language is platform independent, so can run on any operating system including UNIX, Windows or Mac OS. Java language programs are based on the object-oriented concept that is described in this tutorial. There are three basic terminologies associated with Java that are JDK, JRE, and JVM.

Java Development Kit (JDK)

JDK is known as the Java Development Kit. New applications can be developed, executed and compiled with JDK and even the existing applications can also be modified through JDK. On the machine where developers want to develop the applications, JDK must be installed. It further involves JRE and other development, debugging and monitoring tools.

Java Runtime Environment (JRE)

JRE stands for Java Run Time, already developed applications can be executed by JRE. As the name suggests it only provides a runtime environment so new applications cannot be developed by JRE and existing applications cannot be modified as well through JRE.

Java virtual machine (JVM)

JVM means Java Virtual Machine. It drives the java code and bytecode can be run through JVM. By converting the code into machine learning language the code gets executed. Java virtual machine (JVM)

Setting Up Java Environment

To set up the Java environment, if you do not have Java installed on your machine, then you may have to download it from the website of Sun Microsystem and of Eclipse as well. Prior to Eclipse installation, Java environment must be set up and you should have it on your machine.  You can download Java as per your machine requirement.

Eclipse is not just an IDE but is an entire development ecosystem. It has four main components for Java application development and that are:

  • Workspace
  • Project
  • Perspectives
  • Views

Following image shows the Java perspective window of Eclipse. Java perspective window of Eclipse

Eclipse perspective has the tools that are used to write a Java application. A new project must be started to write the new Java application.

Java Object Oriented Programming (OOPS) Concepts

Java is an object-oriented programming language. As it follows the concepts of OOPS as a structured programming language. OOPS follow certain principles that are implemented by Class, Object and other features of Java language like Constructor, Abstraction, Encapsulation, Polymorphism, Inheritance, and Interface and other. OOPS principles are listed below: Java Object Oriented Programming (OOPS) Concepts

Java Tutorial: Class

The class is a blueprint or prototype and objects are created of this prototype. A class contains functions and variables through which objects' behavior is described. Following is an example of a Class declaration in Java:

Class Class_Name{

Member Variable Declaration

Method Definitions

}

Java Tutorial: Object

Object-oriented languages like Java combine program and data into objects. An object is defined as a self-contained entity that has its own attributes and behavior. It has the following properties:

  • Objects have well-defined boundaries
  • It can perform a finite set of operations
  • Objects have only the data information
  • Objects can have their own state that is associated with the value of its attributes

Objects are instances of the Class. Following is the example of object:

Class Class_Name{

Void turnOn{}

Public static void main (String [] args){

Class_Name Obj1=new Class_Name();

Obj1.turnOn();

}

}

In the above example object of Class has been created by the name Obj1 and through it the functions have been called. Methods can be of types:

 

  1. User Defined
  2. Pre Defined

When a user defines any method, then it is known as a user-defined method, while those functions that are already defined in Java are known as Predefined functions.

Java Tutorial: Inheritance

When one class inherits the properties of another class, then it is known as inheritance. Like if we have two classes, one is parent class and the other one is derived class, which is the child class of the parent class, then child class will inherit the properties of the parent class. Inheritance increases the code reusability. Take the example where we have a super or base class named laptop and its subclasses or child classes like Apple, MacBook, Lenovo and other may extend Laptop Class to inherit its properties.

Java Tutorial: Polymorphism

We can perform a task in multiple ways. Polymorphism is made up of two words, one is poly means many and Morphos means shape. Java supports two types of Polymorphism one is runtime polymorphism and other is compile time polymorphism. Here we can take the example of a class named Shape, which may be further divided into shapes like circle, rectangle, triangle and other.

Java Tutorial: Abstraction

To hide the implementation or internal details and show the functionalities to the user we can use the abstraction of Java. It is achieved by using Abstract classes and interfaces. They are defined by using Abstract keywords. Abstract Class has the following properties:

  1. An abstract class may or may not have abstract methods
  2. We cannot instantiate an abstract class
  3. A class has an abstract method must be declared as abstract
  4. Any subclass of abstract class then it must implement all abstract methods of its superclass.

While an abstract method is a method that does not have any method implementation. Moreover, the abstract method can be used in a subclass by overriding its class.

Java Tutorial: Encapsulation

Encapsulation means to bind data and code together in a single unit. Classes are the best encapsulation examples in which various methods, variables, and data are closed in a capsule that is known as class. To wrap all data together is known as encapsulation it provides a secure environment for data.

Java Tutorial: Interfaces

Interfaces look like classes, but both are two different concepts of Java. Methods and variables can be declared in interfaces built by default, these methods are abstract by nature. 100% abstraction can be achieved through multiple inheritances with the interface. They have following properties:

  1. Interfaces represent IS-A relationship
  2. Like abstract classes, Interfaces cannot be instantiated
  3. Public and Abstract, keywords are added by the compiler before Interface methods
  4. A class that implements an interface must implement all methods of the interface
  5. A class can implement more than one interface.

Here is what we cover in the Java Tutorial Guide

Interview Questions and Answers

Other Java Tutorial Topics

 

Wrapping Up!

Java cannot be defined in a single article. There are lots of concepts which are associated with this object-oriented and platform independent programming language. You can find even examples as well in order to implement above-mentioned Java features. Take Java Training and Certification.

    Janbask Training

    JanBask Training is a leading Global Online Training Provider through Live Sessions. The Live classes provide a blended approach of hands on experience along with theoretical knowledge which is driven by certified professionals.


Comments

Java Upcoming Batches

Mon - Fri

6 Weeks

Mon - Fri

6 Weeks

Newsletter