Bubble Sorting in Java

Bubble sorting and Linear sorting are the easiest methods of sorting. Also they are the least optimized sorting algorithms. First we are going to look at bubble sorting in java. In Bubble sort each element is compared with its next element, if the element is greater than the next element then they are swapped. This … Read more

Sorting in Java

Sorting is the process through which elements can be arranged in ascending or descending order. Sorting can be done on numbers, strings etc. In Java inbuilt functions are also available to directly sort the series. These inbuilt functions are provided by Collections framework in Java. Example :- Unsorted series = 24, 20, 100, 203, 1, … Read more

Inheritance in Java

Inheritance is the way through which a class acquires all the properties and members of other class. Inheritance represents the IS-A relationship. The class acquiring the properties is called child class and the class from which properties are acquired is called parent class. We make use of ‘extends‘ keyword for inheritance. With inheritance the child … Read more

Constructor Chaining in Java

Constructor chaining is the way through which a constructor make a call to another constructor. Constructor chaining can be done in 2 ways: Output In the above code we called Example2() constructor for object creation which in turn calls Example2(int age) constructor using this(29). Now inside Example2(int age) constructor a call is made to Example2(int … Read more

Constructor Overloading

Constructor overloading is the way through which multiple constructors can be defined within the class by changing the arguments of the signature. Let us understand this with an example: Output In the above code we have overloaded the constructor by changing the number of parameters in signature. We can use any constructor for creation of … Read more

Parameterized Constructor in Java

Parameterized constructor can be made by the user if they want to assign some value to instance variable at time of creation of object. Parameterized constructors are also a good way to perform some operations that are to be performed at the start such as Database connections, pre-checks on values of instance variables or certain … Read more