Control and Branching Structures in Java.

In this article, Control and Branching Structures in Java is explained in detail with examples.
Control Structure.
In general program execution starts with main() and it follows line by line/linear/sequential flow of execution takes place until the end of main().
Ex:
public static void main(String args[])
{-----
------
body   // (Linear Flow of Execution/Step by step execution)
-----  
------
}

Multiple if and If-else control structures.

In this article,Multiple if and If-else control structures are explained in detail with examples.
In this control structure, we use multiple if statements one after the other/sequential as follows.
Syntax
if(condition 1)
{---
body1;
---
}
if(condition 2)
{---
body2;
------
}

Nested-if control Structure.

In this article,Nested-if control Structure is explained in detail with examples.
In this, you will come to know about the Nested if control structure Using an if-condition block inside another if condition block is known as nested-if.
Syntax
if(condition 1)
{
outer true part;
}
if(condition 2)
{
Inner true part;
}
----
}

Cascading If-else control Structure.

In this article, Cascading If-else control Structure is explained in detail with examples. you will come to know about what is the cascading If-else control structure in Java, how it is defined in java program.Syntax is written as below
Syntax
if (condition 1)
{
true part1;
}
else if (condition 2)
{
true part2;
}
else if (condition 3)

Switch case control structure.

In this article,Switch case control structure is explained in detail with examples.This control structure works same as that of cascading if else provided we use proper break statements and control the execution.
Syntax
switch(expressions)
{
case value1:
---statement1---
break;
case value 2:
---statment2---

Looping Control Structures.

In this article,Looping Control Structures are explained in detail with examples.
These control structures are used to execute a block of statements continuously/iteratively based on a condition.
1.While loop
It is also known as pre-test loop i.e. first, we check the condition and if it is true, then it executes
the body. 
Syntax
initialization;
while(condition)
{
-----
body;
----
increment/decrement;
}

Nested Loop and Labeled break and Labeled continue.

In this article,Nested Loop and Labeled break and Labeled continue is explained in detail with examples.Using a particular looping structure inside an another looping structure is known as nested loop.
Syntax
outer-loop:(no of rows)
{
Inner-loop:(no of columns)
{
----
----
}
}

Getting input from Keyboard.

In this article,Getting input from Keyboard is explained in detail with examples.
"Scanner" is a class, using which, we can accept input from standard input device i.e.Keyboard.
This class is available in java.util package.Such package need to be imported in a java program.
Ex 
import java.util.*; or
import java.util.Scanner;
To use this class,we create object of this class.
Ex
Scanner sc=new Scanner(System.in); //System.in defines standard input device i.e. Keyboard.
for getting the input from keyboard the statement should be in the format shown below
String ss=sc.next(); 
String ss=sc.nextline();     (From topic Getting input from Keyboard)

Arrays in Java.

In this article,Arrays in Java is explained in detail with examples. you will come to know about what are Arrays in Java, how they are defined and how they are initialized in the Java program.
An Array is a collection of elements of same data type.
Syntax
(datatype) array name[]; //array declaration
Ex
int a[]; //no size of array should be given.
In java,while declaring an array, we don't give the size. After declaration, size is allocated to the new operator. (From topic Arrays in Java)
Syntax
arrayname=new (datatype)[size];
Ex
a=new int[5];

Examples on Arrays and ForEach Loop.

In this article,Examples on Arrays and ForEach Loop are explained in detail with examples. we will solve some examples related to the arrays and learn about Foreach Loop.
Ex
//programs related to Examples on Arrays and ForEach Loop--the sum of elements in an array.
class ArraySum
{
public static void main(String args[])
{
int a[]={11,22,33,44,55};
int i,sum=0;
for(i=0;i<5;i++)
sum=sum+a[i];

Possible Array Declarations and 2-D Arrays.

In this article,Possible Array Declarations and 2-D Arrays are explained in detail with examples.
In java we can declare an one dimensional arrays in possible ways.
int a[];
int []a;
int...a; //used only as varargs in methods
          // as last parameter.
Command line arguments
The main method takes string arrays as the input parameter.Such parameters could be passed as arguments while executing the Java program.
Syntax

Matrix addition,subtraction and Wrapper Classes.

In this article,Matrix addition,subtraction and Wrapper Classes are explained in detail with examples.
To perform these operations, the necessary and sufficient condition are both the matrices should be of same order because the operation is performed on corresponding elements from both the matrices.
Ex
//program related to Matrix addition,subtraction and Wrapper Classes-add,subtraction of a matrix.
class MatrixAddSub
{
public static void main(String args[])
{
int a[][]=new int[2][2];
int b[][]=new int[2][2];

Object Class and Constructors in Java.

In this article,Object Class and Constructors in Java are explained in detail with examples.
It is a pre-defined class in java available in "java.lang " package.
This class is a Base-class or Super-class for all our user-defined classes or pre-defined classes directly or indirectly.
This class provides runtime instance for all your classes getting executed in the memory
This class contains 7-native methods.
Native methods are those methods whose implementation is done in other languages like C and C++.
The following methods are native methods in the object class. (From topic Object Class and Constructors in Java)

Constructor and Notations in Java.

In this article,Constructor and Notations in Java are explained in detail with examples.
Like methods, Constructors can also take parameters, which acts like input values to the constructor.
Based on this, constructors are divided into two types.
Constructor types-Javaform

Garbage Collection.

In this article, Garbage Collection is explained in detail with examples.
1.It is an intelligent piece of an algorithm, provided by "JVM", which performs cleaning operations in the memory of java program dynamically when a java program is running for a long period of time.
2.This algorithm checks for unused memory in JVM RAM,and destroys them automatically.
3.In doing so,memory is saved by JVM and RAM becomes free, hence performance of the program increases.
4.This algorithm runs in the background of a program by JVM in memory.
5.This concept is same as that of destructors in C++.
Note
1.This automatic process can also be done by the user by calling the following method.
public void gc();

Deriving a class and Polymorphism in java.

In this article,Deriving a class  and Polymorphism in java are explained in detail with examples.
This concept is related to inheritance.Hence we inherit properties and methods of existing class into a new class.
Deriving a class in Java-Javaform

Method overloading.

In this article,Method overloading is explained in detail with examples.
Two or more methods in a single class with same name and atleast one difference in the signature is known as method loading.
Signature means a number of arguments, the order of arguments and data type of arguments.
Ex
class A
{
---Data members---;
---Constructors----;
void m1(int,int){---}
void m1(float,float){---}
void m1(int,float){---}
void m1(float,int){---}

Method Overriding and Object as a class Member.

In this article,Method Overriding and Object as a class Member are explained in detail with example.
Method overriding is related to inheritance, Here we re-define method of a base class in a subclass with the same name and same signature i.e, the number of arguments, the order of arguments, the data type of arguments, all should be same.
Ex
//program related to Method Overriding and Object as a class Member--method overriding
class ParentClass
{
void parentMethod() //over ridden method---
{
System.out.println("Parent class Method");
}

Method Calling Mechanisms in Java.

In this article,Method Calling Mechanisms in Java is explained in detail with an example.
Based on nature of arguments used to call a user defined method in java, we have two types of method calling mechanisms.They are
  • Call by value.
  • Call by reference.
Call by Value
In this mechanism, we pass a copy of actual arguments to call a user-defined method and formal parameters are also of same data type.
Any changes done with formal parameters are NOT reflected to actual arguments.
Ex
//program related to Method Calling Mechanisms in Java--call by value.

Access Modifiers in Java.

In this article,Access Modifiers in Java is explained in detail with examples.
This concept represents scope/visibility/accessibility of different members of a class for usage.
Java supports four access modifiers:
a.Public
b.Protected
c.Default
d.Private
* If no modifier is used then it is default we use default in the switch case.
Using: D=direct access.
         obj=object access.
Access Modifiers-Javaform

Connect with Us by Subscribing here for more Updates..!

* indicates required