Author: misamaliraza94

  • Futures Overview

    Features of Java The primary objective of Java programming language creation was to make it portable, simple and secure programming language. Apart from this, there are also some excellent features which play an important role in the popularity of this language. The features of Java are also known as Java buzzwords. A list of the most important…

  • Overridden Methods of the superclass

    If methods with the same name are defined in both superclass and subclass, the method in the subclass overrides the method in the superclass. This is called method overriding. Example 1: Method overriding Output In this example, by making an object dog1 of Dog class, we can call its method printMessage() which then executes the display() statement. Since display() is defined in both the classes, the…

  • Create an enum class

    Java program to create an enum class Output In the above example, we have created an enum class named Size. The class contains four constants SMALL, MEDIUM, LARGE, and EXTRALARGE. Here, the compiler automatically converts all the constants of the enum into its instances. Hence, we can call the method using the constant as objects. In this call, the this keyword is…

  • Print object of a class

    Java program to print the object Output In the above example, we have created an object of the class Test. When we print the object, we can see that the output looks different. This is because while printing the object, the toString() method of the object class is called. It formats the object in the default format. That…

  • Implement private constructors

     Java program to create a private constructor Output In the above example, we have created a private constructor of the Test class. Hence, we cannot create an object of the Test class outside of the class. This is why we have created a public static method named instanceMethod() inside the class that is used to create an object of the Test class. And from the Main class,…

  • Determine the class of an object

    Check the class of an object using getClass() Output In the above example, we have used the getClass() method of the Object class to get the class name of the objects obj1 and obj2.

  • Program to perform binary search

    Example Program to perform binary search on a list of integer numbers This program uses binary search algorithm to search an element in given list of elements. Output 1: Output 2:

  • Program for linear search – Example

    Example Program: This program uses linear search algorithm to find out a number among all other numbers entered by user. Output 1: Output 2:

  • Bubble sort in Ascending and descending order

    in this tutorial we are gonna see how to do sorting in ascending & descending order using Bubble sort algorithm. Bubble sort program for sorting in ascending Order Output: Bubble sort program for sorting in descending Order In order to sort in descending order we just need to change the logic array[j] > array[j+1] to array[j] <…

  • Program to calculate area and circumference of circle

    In this tutorial we will see how to calculate area and circumference of circle in Java. There are two ways to do this: 1) With user interaction: Program will prompt user to enter the radius of the circle2) Without user interaction: The radius value would be specified in the program itself. Program 1: Output: Program 2:…