Articles on Trending Technologies

Technical articles with clear explanations and examples

Run-time Stack mechanism in Java

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 1K+ Views

Eeverytime a process or a code or a thread needs to run in Java, a runtime stack is created so as to store the operations performed while executing the thread.Every entry in the run-time stack is known as stack frame or activation record. Once a function has been called by the process, its associated data is deleted from the runtime stack.Once all the functions have been called, the runtime stack will be empty. This means it needs to be removed from the memory.At this point in time, the runtime stack is destroyed and then the thread is also terminated.A termination ...

Read More

Can we call run() method directly instead of start() in Java

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 489 Views

Yes, we can do that. Let us see an example −Exampleclass my_thread extends Thread{    public void run(){       try{          System.out.println ("The thread " + Thread.currentThread().getId() + " is currently running");       }       catch (Exception e){          System.out.println ("The exception has been caught");       }    } } public class Main{    public static void main(String[] args){       int n = 6;       for (int i=1; i

Read More

Check if a number is an Achilles number or not in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 303 Views

ConceptWith respect of given positive integer n, the task is to verify if n is an Achilles number or not. We have to print 'YES' if N is treated as an Achilles number else print 'NO'.Achilles number: With respect of Mathematics, an Achilles number is defined as a number that is powerful (A number N is said to be Powerful Number if it has been noted that for every prime factor p of it, p^2 also divides it) but not a perfect power.In following, the first few Achilles number are displayed72, 108, 200, 288, 392, 432, 500, 648, 675, 800, ...

Read More

How to write an empty function in Java

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 3K+ Views

Let us see how to write an empty function in Java −Exampleimport java.util.Vector; public class Demo{    public static void my_empty_fun(){    }    public static void main(String[] args){       System.out.println("In the main function");       my_empty_fun();    }   }OutputIn the main functionAn empty function is basically creating a function without defining any operations inside it. A class named Demo contains an empty function named ‘my_empty_fun’ which is just completed by placing two flower brackets, without adding any functionality into it. In the main function, a print statement is written after which the empty function is ...

Read More

Widening Primitive Conversion in Java

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 328 Views

Following is an example showing widening primitive conversion −Examplepublic class Demo {    public static void main(String[] args) {       System.out.print("H" + "E");       System.out.print('L');       System.out.print('L');       System.out.print('O');    } }OutputHELLOA class named Demo contains the main function. Here, the ‘print’ function is used to print specific characters in double quotes and then in single quotes. When the process of widening primitive conversion happens, the presence of ‘+’ operator is a must. This ‘+’ operator expects integer on both the left hand and right hand sides.

Read More

Check if a number is Primorial Prime or not in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 447 Views

ConceptWith respect of given positive number n, the task is to verify if n is a primorial prime number or not. We have to print ‘YES’ if n is a primorial prime number otherwise print ‘NO.Primorial Prime − With respect of Mathematics, a Primorial prime is defined as a prime number of the form pN# + 1 or pN# – 1 , where pN# is the primorial of pN such that the product of first N prime numbers.Input − n = 7Output − YES7 is Primorial prime of the form pN + 1 for N=2, Primorial is 2*3 = 6 ...

Read More

Convert one base to other bases in a single Java Program

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 1K+ Views

Let’s say we have an Octal number. To convert Octal to other bases like binary, hexadecimal, etc, the Java code is as follows −Examplepublic class Demo{    public static String base_convert(String num, int source, int destination){       return Integer.toString(Integer.parseInt(num, source), destination);    }    public static void main(String[] args){       String my_num = "345";       int source = 8;       int destination = 2;       System.out.println("Converting the number from octal to binary: "+ base_convert (my_num, source, destination));       destination = 10;       System.out.println("Converting the number from ...

Read More

Java program to convert floating to binary

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 1K+ Views

To convert floating to binary, the Java code is as follows −Exampleimport java.io.*; public class Demo {    static void decimal_to_bin(int n){       int[] bin_num = new int[50];       int i = 0;       while (n > 0){          bin_num[i] = n % 2;          n = n / 2;          i++;       }       for (int j = i - 1; j >= 0; j--)       System.out.print(bin_num[j]);    }    public static void main (String[] args){     ...

Read More

Fill 8 numbers in grid with given conditions in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 241 Views

Suppose we want to place 1, 2, 3, 4, 5, 6, 7, 8, into the eight circles in the given figure, in this way that no number is adjacent to a number that is next to it in the sequence.So, if the input is like0-1-10-1-1-1-10-1-10then the output will beTo solve this, we will follow these steps −N := 3, M := 4NOTCONSIDERED := -1Define a function present_in_grid(), this will take grid[N][M], num, for initialize i := 0, when i < N, update (increase i by 1), do:for initialize j := 0, when j < M, update (increase j by 1), ...

Read More

Java program to generate random numbers within a given range and store in a list

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 471 Views

To generate random numbers in a given range, the Java code is as follows −Exampleimport java.util.Random; import java.util.*; public class Demo{    public static void main(String args[]){       Random my_rand = new Random();       List my_list_1 = new ArrayList();       int v_1 = my_rand.nextInt(1000);       int v_2 = my_rand.nextInt(967);       int v_3 = my_rand.nextInt(1050);       int v_4 = my_rand.nextInt(10000);       int v_5 = my_rand.nextInt(100);       my_list_1.add(v_1);       my_list_1.add(v_2);       my_list_1.add(v_3);       my_list_1.add(v_4);       my_list_1.add(v_5);       System.out.println("The random values in the list are : ");       for(int i=0; i

Read More
Showing 26921–26930 of 61,297 articles
Advertisements