Java Introduction and Installation

Java Fundamentals: Regardless of whether one thinks that Java is now growing, or inactive, or dying, one has to admit that Java had truly revolutionised and had defined the programming language. Java had combined and brought to the tons of useful programming language features that were previously available only separately or in various languages. Java is a programming language and platform Read More

Java Fundamentals

Basic Concepts: The previous topic cleared the compiler and interpreter doubt but still, there are questions such as “How to store different numbers in java?” or “What value you can store in java and how?”, etc. To clear all such doubts we have prepared this “Language Fundamentals” topic which includes the basic concepts to write programs in Java. Here are Read More

Hello Program in Java

: Hello Program Example: class HelloProgram{ public static void main(String args[]){ System.out.println("Hello Intellipaat");//It will print Hello Intellipaat } } Type this program in notepad and save it as Hello.java. Type below commands to Compile and execute the above program: javac HelloProgram.java java HelloProgram Output Hello Intellipaat Program Explanation class: This keyword is used to declare a class in java. public: It is an access modifier that represents Read More

Java Operators

: Operators are the symbols which perform the operation on the some values. These values are known as operands. Java have following operators – Arithmetic Operators Relational Operators Logical Operators Assignment Operators Bitwise Operators Misc Operators Arithmetic Operators Operator Operator Name Description Example + Addition Adds two operands I = 40, J= 20I + J = 60 – Subtraction Subtracts second operand Read More

Basic Datatypes and Variables in Java

: Data Types: There are two types of data types - Primitive Data type Non Primitive Data type Primitive Data Types These are the predefined data types. In java there are 8 primitive data types which are as follows: Data Types Default Values Range Default Size Example boolean False True/ False 1bit boolean b = True char ‘\u0000’ ‘\u0000’ to '\uffff' Read More

Control Statements in Java

Java Loop Iteration Overview: In this section, we are going to discuss about the control statements. Different situations may demand different execution flow of the program. There can be many different conditions which you want your program to follow. Some of these situations can be: You want your program to execute the same statement number of times. You want your Read More

Java Strings

: String is a collection of characters but in this language string is an object which represents a collection of characters. To create string object String class is used. An array of characters is known as String. Create Strings String name = “intellipaat”; OR char[] name={'i','n','t','e','l','l','i','p','a','a',’t’}; The java.lang.String class implements Serializable, Comparable and CharSequence interfaces. The java String is immutable i.e. it cannot be changed Read More

Java Array and Java String Overview

Java Array:: This topic covers the concept of an array. Till now, you have learned the basics of Java by which you can create basic java programs. What if you want to store different numbers of the same type? Will you declare and initialize step by step for each number? But that will be a very lengthy process, time consuming Read More

Java If..Else Statements

: The ability to change the behavior of a piece of code which is based on certain information in the environment is known as conditional code flow. The conditional logic in Scala is primarily based on the “if … else” structure. if Statement If statement is used to test a condition, if condition is true then the code inside Read More

OOPs Concepts

Object Oriented Programming: This topic is about Java OOPs concept. After going through the Java basics such as arrays, language fundamentals, etc. you can start with the OOPs concept. Watch this Java video by Intellipaat: [videothumb class="col-md-12" id="8_JxMy4Gm04" alt="Java Tutorial" title="Java Tutorial"] This topic is to introduce the concept of reusability, to provide security and many more features in Java. Read More

Java Loops

: Loop is used to execute the block of code several times according to the condition given in the loop. It means it execute same code multiple times so it saves code and also helps to traverse the elements of array. There are 3 types of loop: while loop do – while loop for loop while Loop While loop Read More

Encapsulation

: There are three main features of OOPS: Encapsulation Inheritance Polymorphism Wrapping of data and methods into a single unit is known as Encapsulation. It provides the security that keeps data and methods safe from unwanted changes. Class is the example of encapsulation which binds fields and members into a single unit. To get encapsulation using Declare the variables of Read More

Abstract Class and Interface

: Abstract Class Class declared with Abstract keyword is known as abstract class in java. This abstract class have abstract and non-abstract methods. Basically abstract is a process of hiding the properties and showing only functionality to the user. It shows only important things to the user and hides the internal details. abstract class ClassOne { abstract public void method(); public void Read More

Classes and Objects

: Classes It is basically a collection of objects. It is a template which creates objects that defines its state and behavior. A class contains field and method to define the state and behavior of its object. Syntax for Declaring Class: <Access_Modifier> class <Class_Name> Where, Class_Name: It describes the class name which defines by using class keyword. Access_Modifier : It defines the scope of the data member, method or class i.e. who can access Read More

Java Methods

: It is a collection of statement which is used to perform some operation. The main benefit to use method is that it provides code reusability. Once a method is created, then it can be reused multiple times as per requirements. Creating Method To create a method following syntax is used: Access_modifier Return_type Method_name (Parameter_list) { //Body of method } Where, Read More

Java File I/O

Introduction: This document introduces the basic concepts of java File I/O package. What if you want to access a file through code anytime? When you develop any java application then you will get the requirement to interact with various input/output devices. Input-Output devices are the part of underlying hardware and operating system. To interact with the Input-Output devices through java Read More

Exception Handling

Introduction: This topic introduces the basic concept of Exception Handling. As you know, Nobody is perfect in this world. So, what if you are driving a car and suddenly something happens and the car stopped. How will you handle that situation? Say the reason is “No Fuel”. Similarly, while writing a program, if JVM finds something unacceptable then, it throws Read More

Tokens and Variables

: Tokens are the smallest unit of program. There are following tokens in Python: Reserved words Identifiers Literals Operators Reserved Words Reserved Words are also known as keywords which express a special meaning to the compiler and interpreter. Keywords in python are – return or None and not asset def class continue break from finally elif del except global Read More

Multithreading in Java

What is Multi-Threading in Java?: Executing more than one thread simultaneously is called as multithreading. Multithreading is best suitable at the User Application level. Multithreading allows running two or more parts of the programs concurrently. Example: In the above picture, for each deposit or withdraw, separate threads will be allotted for each user. Watch this Java Video [videothumb class="col-md-12" id="gpQU8L3a3f4" Read More

Downcasting and instanceof operator

: Downcasting When child class refers to the object of Parent class then it is known as downcasting. If you perform it directly then it gives compilation error so typecasting is used to perform downcasting but ClassCastException is thrown at runtime. e.g. class Flower { } class Rose extends Flower { static void smell(Flower f) { Rose r = (Rose) f; Read More

Aggregation and Composition (HAS-A)

: Aggregation: It represents HAS-A relationship. Aggregation means a class have an entity reference. It is used because it provides code reusability. Inheritance is also used for code reusability but you should use inheritance when if the relationship IS-A is continued throughout the lifetime of the objects involved otherwise use aggregation. e.g. class CalculationOperation { public float square(float a) { return a*a; Read More

Polymorphism

: Polymorphism is the ability to take more than one form. It means you can perform single action using multiple ways. There are two types of polymorphism: Compile time Polymorphism (Method Overloading) Run time Polymorphism (Method Overriding) 1. Compile time Polymorphism (Method Overloading) - The ability to execute the methods which have same name with different arguments are known Read More

final Keyword in Java

: Keyword final is used along with: Variables Methods Classes final variables: If you use a variable as a final then the value of variable is become constant. You cannot change the value of a final variable once it is initialized. e.g. class Apple{ final int quantity=10; // quantity as a final variable void show(){ quantity=50; } public static void Read More

super keyword in java

: super keyword It is a reference variable which always refers to the immediate parent class object. It performs following operations: 1. Used to call the immediate parent class constructor. e.g. class Fruit{ Fruit(){ System.out.println(“Fruit class created”); } } class Apple extends Fruit{ Apple () { super();//It will call parent class constructor System.out.println(“Apple class created”); } public static void Read More

Java Constructors

: Constructor is a type of method which is used to initialize the object that called at the time of object creation. To create constructor, constructor name should be same as class name and also does not use explicit return type in case of constructor. Types of Java Constructors There are two types of java constructors: Default constructor Parameterized Read More